amphp/react-adapter
最新稳定版本:v2.1.0
Composer 安装命令:
composer require amphp/react-adapter
包简介
Adapter to make any ReactPHP library compatible with Amp.
README 文档
README
amphp/react-adapter makes any ReactPHP library compatible with Amp v2.
Note If you're using AMPHP v3, have a look at
revolt/event-loop-adapter-reactinstead.
Installation
This package can be installed as a Composer dependency.
composer require amphp/react-adapter
Usage
Everywhere where a ReactPHP library requires an instance of LoopInterface, you pass ReactAdapter::get() to run the ReactPHP library on Amp's event loop.
<?php require 'vendor/autoload.php'; use Amp\Loop; use Amp\ReactAdapter\ReactAdapter; Loop::run(function () { $app = function ($request, $response) { $response->writeHead(200, array('Content-Type' => 'text/plain')); $response->end("Hello World\n"); }; $socket = new React\Socket\Server(ReactAdapter::get()); $http = new React\Http\Server($socket, ReactAdapter::get()); $http->on('request', $app); echo "Server running at http://127.0.0.1:1337\n"; $socket->listen(1337); });
You can also use the adapter to run ReactPHP apps on an Amp event loop implementation without relying on Amp's global event loop.
$loop = new Amp\ReactAdapter\ReactAdapter((new Amp\Loop\DriverFactory)->create());
统计信息
- 总下载量: 176.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 24
- 点击次数: 1
- 依赖项目数: 8
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-21