jasonrgd/zf2-websocket-server-factory
Composer 安装命令:
composer require jasonrgd/zf2-websocket-server-factory
包简介
ZF2 PHP WebSocket Server Factory v2.1 (Extended)
README 文档
README
Protocol WebSocket (standard RFC 6455) is designed to solve any problems and the removal of restrictions communication between browser and server.It allows you to transfer any data to any domain, safe and almost without unnecessary network traffic.
The main advantages of this module is that you can create a variety of applications based on Zend Framework 2, where it is necessary to implement persistent connections. Thanks to one interface, you can create a variety of applications and run them on the same server. You can organize a chat, monitor live site visit, you can create real-time statistics and save it to DB (MySQL, Mongo..etc), you can organize the postal service in the likeness of Google. Yes, anything!
Requirements
- PHP 5.4+
- Zend Framework 2.4 >
Changes
v2.2.1 [Request from AdamiecRadek]
- Added support for changing default application namespace
- Added support for multiple namespaces for applications
- Hotfix for proper index in config
v2.1.1
- Fixed service locator which is got ApplicationFactory v2.1
- Select client's application from console like
php -q index.php websocket open <app>
v2.0
- Add "Chat" application as example
- More advanced interface
- Ability to create multiple applications and bind it to the same server
- Detailed log of each ping server's
- The ability to set the maximum number of connections to the server, the maximum number of connections per IP
- Pre defined response errors for Linux, Win platforms (extended by their descriptions)
- Ping using control frames such as PING PONG
v1.3
- Add logger
v1.2
- Add verbose turner (debug show\hide) (@see module.config.php)
- Add socket function's exception handler
- Fixed CLI stdout>> encoding
- Add ViewHelper for a simple get server config params into view
<?php
// for example
echo $this->socket()->config('host'); // print 127.0.0.1
?>
v1.1.2
- Console stdout>> while starting server
v1.1
- Fixes some problem with startup
- Add console command interface for costom system commands (for example)
php -q index.php websocket system "whoami"(Note for ZF2.2): if you have an exceptionsNotice Undefined offset: 0while starting console server please follow this:
vendor\ZF2\library\Zend\Mvc\View\Console\RouteNotFoundStrategy.php 381 and replace line by
<?php
$result .= isset($row[0]) ? $row[0] . "\n" : '';
?>
It might be fixed until not fix in the next update. You're always can ask me for this module if you have write me issue
Installation and Running Server :
- First update your dependencies through composer. Then run to update dependency and update autoloader
php composer.phar require stanislav-web/zf2-websocket-server-factory
php composer.phar install -o
-
That needs to be done is adding it to your application's list of active modules. Add module "WebSockets" in your application.config.php
-
Perform module configuration file module.config.php
-
Go to your shell command-line interface and type (running server as background):
php -q index.php websocket open <app>(app like as your client application) -
Setup your Client-side script's to communicating with the server .. ws://host:port/websocket/open/
How can i do the Application ?
New application you can do according to the rules interface
src\WebSockets\Aware\ApplicationInterface.php
As an example, you can see the implementation "Chat"
src\WebSockets\Application\Chat.php
then call server from your cli controller
<?php
// get factory container
$factory = new ApplicationFactory($this->getServiceLocator());
// applications from response <app>
// get it @see /src/WebSockets/Application/Chat.php etc..
$client = $request->getParam('app');
$app = $factory->dispatch(ucfirst($client));
// bind events from application
// ! must be implements of your every new Application
$app->bind('open', 'onOpen');
$app->bind('message', 'onMessage');
$app->bind('close', 'onClose');
// running server
$app->run();
?>
In order to start using the module clone the repo in your vendor directory or add it as a submodule if you're already using git for your project:
git clone https://github.com/stanislav-web/ZF2-PHP-WebSocket-Server-Factory.git vendor/WebSockets or git submodule add git clone https://github.com/stanislav-web/ZF2-PHP-WebSocket-Server-Factory.git vendor/WebSockets
The module will also be available as a Composer package soon.
Libraries used
- Zend Framework 2.4
- [WebSocket Protocol] (http://tools.ietf.org/html/rfc6455)
- This repository is the continuation of the module from which I started work [https://github.com/stanislav-web/ZF2-PHP-WebSocket-Server] (https://github.com/stanislav-web/ZF2-PHP-WebSocket-Server)
jasonrgd/zf2-websocket-server-factory 适用场景与选型建议
jasonrgd/zf2-websocket-server-factory 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 04 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「zf2」 「WebSockets」 「websocket server」 「websocket chat」 「websockets php」 「websocket php server」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jasonrgd/zf2-websocket-server-factory 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jasonrgd/zf2-websocket-server-factory 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jasonrgd/zf2-websocket-server-factory 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LosLog provides some log utility
EdpModuleLayouts is very simple Laminas module for making module-specific layouts insanely easy.
Thruway WAMP router core
Zend Framework module to leverage the symfony dependency injection container
RCM User HTML views/pages
Builds a Bridge between Zend Expressive and Plugin Managers of Zend\MVC
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-23