1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-23 09:34:00 +01:00
guzzle/docs/index.rst
Michael Dowling 0949947ee2 Updating docs
2015-03-28 15:33:35 -07:00

53 lines
1.6 KiB
ReStructuredText

.. title:: Guzzle | PHP HTTP client and framework for consuming RESTful web services
======
Guzzle
======
Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
trivial to integrate with web services.
- Manages things like persistent connections, simplifies sending streaming
POST requests with fields and files, and abstracts away the underlying HTTP
transport layer.
- Can send both synchronous and asynchronous requests.
- Pluggable HTTP handlers allows Guzzle to integrate with any method you choose
for sending HTTP requests over the wire (e.g., cURL, sockets, PHP's stream
wrapper, non-blocking event loops like `React <http://reactphp.org/>`_, etc.).
- Guzzle makes it so that you no longer need to fool around with cURL options,
stream contexts, or sockets.
- Middleware system allows you to augment the behavior of a client.
.. code-block:: php
$client = new GuzzleHttp\Client();
$response = $client->get('http://guzzlephp.org');
$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"...'
// Send an asynchronous request.
$promise = $client->getAsync('http://httpbin.org');
$promise->then(function ($response) {
echo 'I completed! ' . $response->getStatusCode();
});
User guide
----------
.. toctree::
:maxdepth: 2
overview
quickstart
clients
psr7
handlers-and-middleware
testing
faq