veewee / psr18-react-browser
一个用于react浏览器的PSR-18桥梁
1.1.0
2023-11-24 08:02 UTC
Requires
- php: ~8.1 || ~8.2 || ~8.3
- psr/http-client: ^1.0
- react/async: ^4.1
- react/http: ^1.9
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.30
- nyholm/psr7: ^1.8
- phpunit/phpunit: ^10.3
- symfony/process: ^6.3
- veewee/composer-run-parallel: ^1.2
- vimeo/psalm: ^5.15
Provides
README
composer require veewee/psr18-react-browser
<?php use React\Http\Browser; use Veewee\Psr18ReactBrowser\Psr18ReactBrowserClient; $psr18Client = new Psr18ReactBrowserClient( new Browser() ); $psr18Client->sendRequest($request);
异步
自PHP 8.1引入纤程以来,此客户端可用于并行使用
<?php use function React\Async\async; use function React\Async\await; use function React\Async\parallel; $run = fn($id) => async(fn () => $psr18Client->sendRequest($buildRequestFor($id))); $responses = await(parallel([ $run(1), $run(2), $run(3), ]));