sanchescom/laravel-phpsocket.io
Composer 安装命令:
composer require sanchescom/laravel-phpsocket.io
包简介
Laravel phpsocket.io
关键字:
README 文档
README
Laravel with phpsocket.io
This is Laravel package for phpsocket.io which is a server side alternative implementation of socket.io in PHP based on Workerman.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Installing
Require this package, with Composer, in the root directory of your project.
$ composer require sanchescom/laravel-phpsocket.io
Create SocketServiceProvider.php in app/Providers
<?php namespace App\Providers; use Sanchescom\LaravelSocketIO\SocketServiceProvider as ServiceProvider; use App\Sockets\ExampleSocket; /** * Class SocketServiceProvider. */ class SocketServiceProvider extends ServiceProvider { /** * The socket handlers for the application. * * @var array */ protected $sockets = [ ExampleSocket::class, ]; }
Laravel 5.x:
After updating composer, add the ServiceProvider to the providers array in config/app.php
'providers' => [ ... App\Providers\SocketServiceProvider::class, ],
Lumen:
After updating composer add the following lines to register provider in bootstrap/app.php
$app->register(App\Providers\SocketServiceProvider::class);
Usage
Create folder app\Sockets and put there ExampleSocket.php
<?php namespace App\Sockets; use PHPSocketIO\SocketIO; use Sanchescom\LaravelSocketIO\Sockets\AbstractSocket; use Workerman\Lib\Timer; class ExampleSocket extends AbstractSocket { /** * @var int */ const TIME_INTERVAL = 4; /** * @var int */ protected $port = 2020; /** * @var array */ protected $options = []; /** * @param SocketIO $socketIO */ public function call(SocketIO $socketIO): void { $socketIO->on('workerStart', function () use ($socketIO) { Timer::add(self::TIME_INTERVAL, function () use ($socketIO) { $socketIO->to('room')->emit('score', [ 'items' => [ [ 'id' => 1, 'message' => 'Hello world' ], ] ]); }); }); $socketIO->on('connection', function ($socket) { $socket->join('room'); }); } }
Running
Start
$ ./vendor/bin/socket start
Stop:
$ ./vendor/bin/socket stop
Status
$ ./vendor/bin/socket status
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Efimov Aleksandr - Initial work - Sanchescom
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
sanchescom/laravel-phpsocket.io 适用场景与选型建议
sanchescom/laravel-phpsocket.io 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 107 次下载、GitHub Stars 达 10, 最近一次更新时间为 2019 年 03 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Socket.io」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sanchescom/laravel-phpsocket.io 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sanchescom/laravel-phpsocket.io 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sanchescom/laravel-phpsocket.io 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Video Chat using Socket.IO and WebRTC
Alfabank REST API integration
Socket.io laravel broadcaster
A chat module built for laravel using socket.io
Laravel Video Chat using Socket.IO and WebRTC
A symfony package bundle for Node.Js event-driven socket application.
统计信息
- 总下载量: 107
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-20