squirtle/websocket
Composer 安装命令:
composer require squirtle/websocket
包简介
Websocket client and server for Laravel
README 文档
README
This package provides a flexible and high-performance solution that facilitates real-time communication in your Laravel applications.
Features
- WebSocket Client & Server: Real-time, low-latency, and scalable client-server communication.
- Pub/Sub Management: A flexible pub/sub architecture for efficient message publishing and sharing.
- Event-Based Listening: You can listen to events created for both the client and server to execute operations.
- Extensible Architecture: Driver and broker infrastructure easily extendable to meet your needs.
Requirements
- PHP 8.2 or higher
- Laravel 10.x or higher
- Swoole Extension
- Redis (For broker support)
Installation
Installation via Composer
Use Composer to add the package to your Laravel project:
composer require squirtle/websocket
Configuration
After installing the package, publish the configuration files:
php artisan vendor:publish --provider="Squirtle\WebSocket\WebSocketServiceProvider"
In the published config/websocket.php file, you can configure Swoole, Redis, and other settings according to your
needs.
Usage
Starting the WebSocket Client
You can start your WebSocket client using the following Artisan command:
php artisan websocket:client
php artisan websocket:client --broker=redis --driver=swoole --host=127.0.0.1 --port=6001 --debug
Starting the WebSocket Server
You can start your WebSocket server using the following Artisan command:
php artisan websocket:serve
Event Listening
By creating listener classes, you can listen to events on the WebSocket client/server and perform actions accordingly.
Extensibility
Extending the WebSocket Client
To add your own WebSocket client driver instead of the default Swoole driver, implement the ClientInterface. Define
the
required methods and configure the package’s settings to make the new driver selectable.
Extending the WebSocket Server
By default, the Swoole driver is used, but you can add your own WebSocket driver to meet your specific needs. To do
this, implement the ServerInterface, define the required methods, and make the new driver selectable from the
package’s
configuration file.
Extending the Broker System
To integrate different broker systems besides Redis, implement the PubSubManager interface to create your custom
broker class. Then, configure the necessary settings in your configuration file to activate the new broker.
Contributing
We welcome your contributions! For new feature suggestions, bug fixes, and improvements, please submit a pull request or provide feedback in the issues section.
License
This package is licensed under the MIT License. For details, please refer to the LICENSE file.
squirtle/websocket 适用场景与选型建议
squirtle/websocket 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「websocket」 「real-time」 「WebSockets」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 squirtle/websocket 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 squirtle/websocket 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 squirtle/websocket 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Talk is a Laravel based realtime messaging, chatting and conversation system. It helps to develop users messaging, chatting and conversations in easy way.
Thruway WAMP router core
Boxalino Real Time User Experience (RTUX) Magento2 plugin
A Laravel Nova tool to integrate websockets into Nova.
Laravel package for generating Agora.io tokens (RTC, RTM, Chat) with support for both V1 and V2 token formats
PHP library for Broadcastt HTTP API
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-09