1
.. title:: Guzzle | PHP HTTP client and framework for consuming RESTful web services
7
Guzzle is a PHP HTTP client that makes it easy to work with HTTP/1.1 and takes
8
the pain out of consuming web services.
10
- Pluggable HTTP adapters that can send requests serially or in parallel
11
- Doesn't require cURL, but uses cURL by default
12
- Streams data for both uploads and downloads
13
- Provides event hooks & plugins for cookies, caching, logging, OAuth, mocks, etc.
14
- Keep-Alive & connection pooling
16
- Automatic decompression of response bodies
17
- Streaming multipart file uploads
22
$client = new GuzzleHttp\Client();
23
$res = $client->get('https://api.github.com/user', [
24
'auth' => ['user', 'pass']
26
echo $res->getStatusCode(); // 200
27
echo $res->getHeader('content-type'); // 'application/json; charset=utf8'
28
echo $res->getBody(); // {"type":"User"...'
29
var_export($res->json()); // Outputs the JSON decoded data
50
There are a number of optional libraries you can use along with Guzzle's HTTP
51
layer to add capabilities to the client.
53
`Log Subscriber <https://github.com/guzzle/log-subscriber>`_
54
Logs HTTP requests and responses sent over the wire using customizable
55
log message templates.
57
`OAuth Subscriber <https://github.com/guzzle/oauth-subscriber>`_
58
Signs requests using OAuth 1.0.
60
`Progress Subscriber <https://github.com/guzzle/progress-subscriber>`_
61
Emits progress events when uploading and downloading data.
63
`Cache Subscriber <https://github.com/guzzle/cache-subscriber>`_
64
Implements a private transparent proxy cache that caches HTTP responses.
66
`Retry Subscriber <https://github.com/guzzle/retry-subscriber>`_
67
Retries failed requests using customizable retry strategies (e.g., retry
68
based on response status code, cURL error codes, etc.)
70
`Message Integrity Subscriber <https://github.com/guzzle/message-integrity-subscriber>`_
71
Verifies the message integrity of HTTP responses using customizable
72
validators. This plugin can be used, for example, to verify the Content-MD5
75
Service Description Commands
76
----------------------------
78
You can use the **Guzzle Command** library to encapsulate interaction with a
79
web service using command objects. Building on top of Guzzle's command
80
abstraction allows you to easily implement things like service description that
81
can be used to serialize requests and parse responses using a meta-description
84
`Guzzle Command <https://github.com/guzzle/command>`_
85
Provides the foundational elements used to build high-level, command based,
86
web service clients with Guzzle.
88
`Guzzle Services <https://github.com/guzzle/guzzle-services>`_
89
Provides an implementation of the *Guzzle Command* library that uses
90
Guzzle service descriptions to describe web services, serialize requests,
91
and parse responses into easy to use model structures.