2013-10-31 15:25:29 -07:00
|
|
|
.. title:: Guzzle | PHP HTTP client and framework for consuming RESTful web services
|
2014-02-13 20:05:40 -08:00
|
|
|
|
|
|
|
======
|
|
|
|
Guzzle
|
|
|
|
======
|
|
|
|
|
2014-02-15 23:40:24 -08:00
|
|
|
Guzzle is a PHP HTTP client that makes it easy to work with HTTP/1.1 and takes
|
|
|
|
the pain out of consuming web services.
|
2014-02-13 20:05:40 -08:00
|
|
|
|
2014-02-15 23:40:24 -08:00
|
|
|
- Pluggable HTTP adapters that can send requests serially or in parallel
|
|
|
|
- Doesn't require cURL, but uses cURL by default
|
|
|
|
- Streams data for both uploads and downloads
|
2014-05-04 17:06:53 -04:00
|
|
|
- Provides event hooks & plugins for cookies, caching, logging, OAuth, mocks, etc.
|
2014-02-15 23:40:24 -08:00
|
|
|
- Keep-Alive & connection pooling
|
|
|
|
- SSL Verification
|
|
|
|
- Automatic decompression of response bodies
|
|
|
|
- Streaming multipart file uploads
|
|
|
|
- Connection timeouts
|
2014-02-13 20:05:40 -08:00
|
|
|
|
|
|
|
.. code-block:: php
|
|
|
|
|
|
|
|
$client = new GuzzleHttp\Client();
|
2014-03-30 15:40:51 -07:00
|
|
|
$res = $client->get('https://api.github.com/user', [
|
|
|
|
'auth' => ['user', 'pass']
|
|
|
|
]);
|
|
|
|
echo $res->getStatusCode(); // 200
|
|
|
|
echo $res->getHeader('content-type'); // 'application/json; charset=utf8'
|
|
|
|
echo $res->getBody(); // {"type":"User"...'
|
|
|
|
var_export($res->json()); // Outputs the JSON decoded data
|
2014-02-13 20:05:40 -08:00
|
|
|
|
|
|
|
User guide
|
|
|
|
----------
|
|
|
|
|
|
|
|
.. toctree::
|
|
|
|
:maxdepth: 2
|
|
|
|
|
|
|
|
overview
|
|
|
|
quickstart
|
|
|
|
clients
|
2014-02-16 17:10:57 -08:00
|
|
|
http-messages
|
2014-02-13 23:37:34 -08:00
|
|
|
events
|
2014-02-13 20:05:40 -08:00
|
|
|
streams
|
2014-03-12 19:00:11 -07:00
|
|
|
adapters
|
2014-03-24 21:10:05 -07:00
|
|
|
testing
|
2014-02-13 20:05:40 -08:00
|
|
|
faq
|
|
|
|
|
2014-03-01 17:37:34 -08:00
|
|
|
HTTP Components
|
|
|
|
---------------
|
2014-02-13 20:05:40 -08:00
|
|
|
|
2014-03-01 17:37:34 -08:00
|
|
|
There are a number of optional libraries you can use along with Guzzle's HTTP
|
|
|
|
layer to add capabilities to the client.
|
2014-02-13 20:05:40 -08:00
|
|
|
|
2014-03-01 17:37:34 -08:00
|
|
|
`Log Subscriber <https://github.com/guzzle/log-subscriber>`_
|
2014-03-17 16:10:57 -04:00
|
|
|
Logs HTTP requests and responses sent over the wire using customizable
|
2014-03-01 17:37:34 -08:00
|
|
|
log message templates.
|
|
|
|
|
|
|
|
`OAuth Subscriber <https://github.com/guzzle/oauth-subscriber>`_
|
|
|
|
Signs requests using OAuth 1.0.
|
|
|
|
|
|
|
|
`Cache Subscriber <https://github.com/guzzle/cache-subscriber>`_
|
|
|
|
Implements a private transparent proxy cache that caches HTTP responses.
|
|
|
|
|
|
|
|
`Retry Subscriber <https://github.com/guzzle/retry-subscriber>`_
|
|
|
|
Retries failed requests using customizable retry strategies (e.g., retry
|
2014-05-04 17:06:53 -04:00
|
|
|
based on response status code, cURL error codes, etc.)
|
2014-03-01 17:37:34 -08:00
|
|
|
|
|
|
|
`Message Integrity Subscriber <https://github.com/guzzle/message-integrity-subscriber>`_
|
|
|
|
Verifies the message integrity of HTTP responses using customizable
|
|
|
|
validators. This plugin can be used, for example, to verify the Content-MD5
|
|
|
|
headers of responses.
|
|
|
|
|
|
|
|
Service Description Commands
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
You can use the **Guzzle Command** library to encapsulate interaction with a
|
|
|
|
web service using command objects. Building on top of Guzzle's command
|
|
|
|
abstraction allows you to easily implement things like service description that
|
|
|
|
can be used to serialize requests and parse responses using a meta-description
|
|
|
|
of a web service.
|
|
|
|
|
|
|
|
`Guzzle Command <https://github.com/guzzle/command>`_
|
|
|
|
Provides the foundational elements used to build high-level, command based,
|
|
|
|
web service clients with Guzzle.
|
2014-02-13 20:05:40 -08:00
|
|
|
|
2014-03-01 17:37:34 -08:00
|
|
|
`Guzzle Services <https://github.com/guzzle/guzzle-services>`_
|
|
|
|
Provides an implementation of the *Guzzle Command* library that uses
|
|
|
|
Guzzle service descriptions to describe web services, serialize requests,
|
|
|
|
and parse responses into easy to use model structures.
|