admsa / larachet
Laravel 5 和 Ratchet 集成
dev-master
2015-03-10 09:33 UTC
Requires
- cboden/ratchet: 0.3.*
- guzzle/guzzle: ~3.9
- react/zmq: 0.3.*
Requires (Dev)
- phpspec/phpspec: ~2.1
This package is not auto-updated.
Last update: 2024-09-28 17:12:36 UTC
README
Laravel 5 和 Ratchet 集成
使用说明
需要 composer
"admsa/larachet": "dev-master"
将提供者添加到您的 config/app.php 配置文件中
'providers' => [
// Existing providers
'Admsa\Larachet\LarachetServiceProvider',
]
将外观别名添加到您的 config/app.php 配置文件中
'aliases' => [
// Existing aliases
'Larachet' => 'Admsa\Larachet\LarachetFacade'
]
$data = [];
Larachet::push('kittens-category', $data);
JavaScript 代码使用
var r = new Larachet('ws://:8080');
r.watch('kittens-category', function(topic, data) {
console.log('New article published to category "' + topic + '" : ' + JSON.stringify(data));
});
r.watch('puppy-category', function(topic, data) {
console.log('New article published to category "' + topic + '" : ' + JSON.stringify(data));
});
注意
此项目仍在开发中。
JavaScript 代码已加载。请检查 HTML 源代码。
参考资料
http://blog.alexandervn.nl/2012/05/03/install-zeromq-php-ubuntu