• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Askedio/laravel-ratchet: A Ratchet Server built for Laravel

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

Askedio/laravel-ratchet

开源软件地址(OpenSource Url):

https://github.com/Askedio/laravel-ratchet

开源编程语言(OpenSource Language):

PHP 95.8%

开源软件介绍(OpenSource Introduction):

Laravel Ratchet Server

This package enables you to create and run a fully functioning WebSocket server in your Laravel app. It can optionally receive messages broadcast over ZeroMQ.

Requirements

  • PHP 7.1+
  • Laravel 5.5+
  • ZeroMQ
  • ext-zmq for PHP

Installation

$ composer require askedio/laravel-ratchet

The service provider is loaded automatically in Laravel 5.5 using Package Autodiscovery.

Publish the vendor files so you can configure your server defaults.

$ php artisan vendor:publish --provider="Askedio\LaravelRatchet\Providers\LaravelRatchetServiceProvider"

Starting the Server

After completing installation, the quickest way to start a standard WebSocket server is simply by running:

$ php artisan ratchet:serve --driver=WsServer

This will run a simple example server based on src/Examples/Pusher.php.

It's possible to create a WampServer or an IoServer also. Use the --help switch on the command to find out more.

You should create your own server class inside your app folder by extending one of the core Ratchet server classes: RatchetWsServer.php or RatchetWampServer.php.

Then update your config/ratchet.php file to point to your server class.

Use with Laravel Broadcasting

To use broadcasting in your Laravel app with the server you create, you will need a ZeroMQ broadcast driver for Laravel (e.g. this one).

You will also need to tell your Ratchet server to bind to a ZeroMQ socket. You can do this simply by passing the -z option, i.e.:

$ php artisan ratchet:serve --driver=WsServer -z

This will connect to the socket you define in your config/ratchet.php settings and listen for messages from ZeroMQ.

To handle messages published via ZeroMQ, simply add a public function onEntry($messages) method to your server class. This will allow you to receive messages inside your Ratchet server instance and determine how to route them.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap