scheldejonas / guzzlehttpringphp
提供简单的API和规范,将HTTP的细节抽象成一个PHP函数。
1.1.2
2020-11-12 11:00 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
Replaces
README
提供简单的API和规范,将HTTP的细节抽象成一个PHP函数。RingPHP可以通过接受一个请求哈希并通过使用promise返回一个响应哈希来驱动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/。