React适配器
amphp/react-adapter使任何库与兼容。
安装
composer require amphp/react-adapter
用法
在ReactPHP库需要LoopInterface实例的LoopInterface ,只需传递ReactAdapter::get()即可在Amp的事件循环上运行ReactPHP库。
<?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 = ne
1