guzzlehttp / ring
1.1.1
2018-07-31 13:22 UTC
Requires
- php: >=5.4.0
- guzzlehttp/streams: ~3.0
- react/promise: ~2.0
Requires (Dev)
- ext-curl: *
- phpunit/phpunit: ~4.0
Suggests
- ext-curl: Guzzle will use specific adapters if cURL is present
README
提供了一个简单的API和规范,将HTTP的细节抽象到一个PHP函数中。RingPHP可以通过接收一个请求哈希并返回一个使用promise来满足的响应哈希的PHP函数来驱动HTTP客户端和服务器,从而支持同步和异步工作流程。
通过抽象不同HTTP客户端和服务器实现的细节,RingPHP允许您在不将应用程序绑定到特定实现的情况下使用可插拔的HTTP客户端和服务器。
<?php require 'vendor/autoload.php'; use GuzzleHttp\Ring\Client\CurlHandler; $handler = new CurlHandler(); $response = $handler([ 'http_method' => 'GET', 'uri' => '/', 'headers' => [ 'host' => ['www.google.com'], 'x-foo' => ['baz'] ] ]); $response->then(function (array $response) { echo $response['status']; }); $response->wait();
RingPHP受到Clojure的Ring的启发,而Ring则受到Python的WSGI和Ruby的Rack的启发。RingPHP在Guzzle 5.0+中被用作处理层来发送HTTP请求。
文档
完整在线文档请访问 http://ringphp.readthedocs.org/。