README.md
1Guzzle, PHP HTTP client and webservice framework
2================================================
3
4[![Build Status](https://secure.travis-ci.org/guzzle/guzzle.svg?branch=master)](http://travis-ci.org/guzzle/guzzle)
5
6Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
7trivial to integrate with web services.
8
9- Manages things like persistent connections, represents query strings as
10 collections, simplifies sending streaming POST requests with fields and
11 files, and abstracts away the underlying HTTP transport layer.
12- Can send both synchronous and asynchronous requests using the same interface
13 without requiring a dependency on a specific event loop.
14- Pluggable HTTP adapters allows Guzzle to integrate with any method you choose
15 for sending HTTP requests over the wire (e.g., cURL, sockets, PHP's stream
16 wrapper, non-blocking event loops like ReactPHP.
17- Guzzle makes it so that you no longer need to fool around with cURL options,
18 stream contexts, or sockets.
19
20```php
21$client = new GuzzleHttp\Client();
22$response = $client->get('http://guzzlephp.org');
23$res = $client->get('https://api.github.com/user', ['auth' => ['user', 'pass']]);
24echo $res->getStatusCode();
25// "200"
26echo $res->getHeader('content-type');
27// 'application/json; charset=utf8'
28echo $res->getBody();
29// {"type":"User"...'
30var_export($res->json());
31// Outputs the JSON decoded data
32
33// Send an asynchronous request.
34$req = $client->createRequest('GET', 'http://httpbin.org', ['future' => true]);
35$client->send($req)->then(function ($response) {
36 echo 'I completed! ' . $response;
37});
38```
39
40Get more information and answers with the
41[Documentation](http://guzzlephp.org/),
42[Forums](https://groups.google.com/forum/?hl=en#!forum/guzzle),
43and [Gitter](https://gitter.im/guzzle/guzzle).
44
45### Installing via Composer
46
47The recommended way to install Guzzle is through
48[Composer](http://getcomposer.org).
49
50```bash
51# Install Composer
52curl -sS https://getcomposer.org/installer | php
53```
54
55Next, run the Composer command to install the latest stable version of Guzzle:
56
57```bash
58composer.phar require guzzlehttp/guzzle
59```
60
61After installing, you need to require Composer's autoloader:
62
63```php
64require 'vendor/autoload.php';
65```
66
67### Documentation
68
69More information can be found in the online documentation at
70http://guzzlephp.org/.
71