catalyst/swoole-foundation
Composer 安装命令:
composer require catalyst/swoole-foundation
包简介
Catalyst Swoole Foundation
README 文档
README
Swoole Foundation Library
What is the Swoole Foundation
The swoole foundation is a factory foundation to easily create swoole server instances. The orchestration of settings and events is closure based.
Dependencies
This Package depends on catalyst/servant.
Creating a Swoole Server
use Catalyst\Swoole\{ ServerFactory, Entities\ServerEvents, Entities\ServerConfiguration }; $factory = new ServerFactory(); $server = $factory->server(function(ServerConfiguration $settings, ServerEvents $events) { $settings->withBinding('::', 9508); $events->onStart(function() { echo 'Server started!'; }); });
Creating a Swoole Http Server
use Catalyst\Swoole\{ ServerFactory, Entities\HttpServerEvents, Entities\ServerConfiguration }; $factory = new ServerFactory(); $server = $factory->httpServer(function(ServerConfiguration $settings, HttpServerEvents $events) { $settings->withBinding('::', 80); $events->onRequest(function(swoole_http_request $request, swoole_http_respose $response) { $response->end('Hello World!'); }); });
Creating a Swoole Websocket Server
use Catalyst\Swoole\{ ServerFactory, Entities\HttpServerEvents, Entities\ServerConfiguration }; $factory = new ServerFactory(); $server = $factory->webSocketServer(function(ServerConfiguration $settings, HttpServerEvents $events) { $settings->withBinding('::', 80); $events->onRequest(function(swoole_http_request $request, swoole_http_respose $response) { $response->end('Hello World!'); }); });
Servant awareness
The Factory implementation is servant aware and allows to chain additional servants to the given servants. Due to implementation decisions, you can not replace the first servant. An exception will be thrown when you try to set a different servant.
License and Maintainer(s)
This package is licensed under the MIT license. This package is actively maintained by:
- Matthias Kaschubowski
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-28