index.rst 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. =======
  2. RingPHP
  3. =======
  4. Provides a simple API and specification that abstracts away the details of HTTP
  5. into a single PHP function. RingPHP be used to power HTTP clients and servers
  6. through a PHP function that accepts a request hash and returns a response hash
  7. that is fulfilled using a `promise <https://github.com/reactphp/promise>`_,
  8. allowing RingPHP to support both synchronous and asynchronous workflows.
  9. By abstracting the implementation details of different HTTP clients and
  10. servers, RingPHP allows you to utilize pluggable HTTP clients and servers
  11. without tying your application to a specific implementation.
  12. .. toctree::
  13. :maxdepth: 2
  14. spec
  15. futures
  16. client_middleware
  17. client_handlers
  18. testing
  19. .. code-block:: php
  20. <?php
  21. require 'vendor/autoload.php';
  22. use GuzzleHttp\Ring\Client\CurlHandler;
  23. $handler = new CurlHandler();
  24. $response = $handler([
  25. 'http_method' => 'GET',
  26. 'uri' => '/',
  27. 'headers' => [
  28. 'host' => ['www.google.com'],
  29. 'x-foo' => ['baz']
  30. ]
  31. ]);
  32. $response->then(function (array $response) {
  33. echo $response['status'];
  34. });
  35. $response->wait();
  36. RingPHP is inspired by Clojure's `Ring <https://github.com/ring-clojure/ring>`_,
  37. which, in turn, was inspired by Python's WSGI and Ruby's Rack. RingPHP is
  38. utilized as the handler layer in `Guzzle <http://guzzlephp.org>`_ 5.0+ to send
  39. HTTP requests.