wyrihaximus / react-guzzle
1.0.0
2015-08-11 07:32 UTC
Requires
- guzzlehttp/guzzle: ~4.0
- guzzlehttp/psr7: ^1.1
- react/dns: ^0.4.1
- react/http-client: ^0.4.0
- wyrihaximus/react-guzzle-http-client: ^3.0.0
Requires (Dev)
- phake/phake: ~1.0.6
- phpunit/phpunit: ~4.0
- squizlabs/php_codesniffer: ~1.5.0
- vectorface/dunit: ~2.0
Suggests
- guzzlehttp/oauth-subscriber: 0.1.* needed for oauth example
This package is auto-updated.
Last update: 2022-02-01 12:33:41 UTC
README
ReactPHP HttpClient 适配器用于 Guzzle4,Guzzle5 查看请点击 ReactGuzzleRing,Guzzle6 查看请点击 react-guzzle-psr7
安装
要使用 Composer 安装,请使用以下命令,它将自动检测最新版本并将其绑定到 ~
。
composer require wyrihaximus/react-guzzle
基本用法
<?php require dirname(__DIR__) . '/vendor/autoload.php'; use GuzzleHttp\Client; use GuzzleHttp\Message\Response; use React\EventLoop\Factory; use WyriHaximus\React\Guzzle\HttpClientAdapter; use WyriHaximus\React\Guzzle\HttpClient\ProgressInterface; // Create eventloop $loop = Factory::create(); $client = new Client([ 'adapter' => new HttpClientAdapter($loop), ]); $client->get('http://docs.guzzlephp.org/en/latest/')->then(function(Response $response) { // Success callback var_export($response); }, function($event) { // Error callback var_export($event); }, function(ProgressInterface $event) { // Progress callback var_export($event); }); $loop->run();
有关更多使用此适配器的方法,请参阅 示例 目录。
关于 save_to 的注意事项
在 react 中,文件 I/O 是阻塞的,并且不一定与某些事件循环很好地配合。因此,请谨慎使用 save_to
,因为它将具有次优性能。
许可证
版权所有 2014 Cees-Jan Kiewiet
特此授予任何人获得此软件及其相关文档文件(“软件”)副本(“软件”)的权利,免费处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本,并允许软件提供方进行此类操作,但受以下条件约束
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、适用于特定目的和无侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论此类责任基于合同、侵权或其他方式,源于、因之或与此软件或软件的使用或其他交易有关。