1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-01-17 21:38:16 +01:00
guzzle/README.md

90 lines
3.3 KiB
Markdown
Raw Normal View History

2015-03-28 15:36:00 -07:00
Guzzle, PHP HTTP client
=======================
2011-11-11 17:21:41 -06:00
2016-06-20 09:52:22 +03:00
[![Build Status](https://travis-ci.org/guzzle/guzzle.svg?branch=master)](https://travis-ci.org/guzzle/guzzle)
2013-06-10 13:47:53 -07:00
2014-10-09 23:04:32 -07:00
Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
trivial to integrate with web services.
2014-10-08 18:35:23 -07:00
2015-03-29 11:10:33 -07:00
- Simple interface for building query strings, POST requests, streaming large
uploads, streaming large downloads, using HTTP cookies, uploading JSON data,
etc...
- Can send both synchronous and asynchronous requests using the same interface.
- Uses PSR-7 interfaces for requests, responses, and streams. This allows you
to utilize other PSR-7 compatible libraries with Guzzle.
- Abstracts away the underlying HTTP transport, allowing you to write
environment and transport agnostic code; i.e., no hard dependency on cURL,
PHP streams, sockets, or non-blocking event loops.
2015-03-29 12:34:54 -07:00
- Middleware system allows you to augment and compose client behavior.
2013-06-03 23:12:35 -07:00
```php
2016-07-01 11:23:17 +02:00
$client = new \GuzzleHttp\Client();
2016-11-15 18:51:04 +09:00
$res = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
2014-03-18 10:27:47 -07:00
echo $res->getStatusCode();
// 200
2015-12-29 13:27:26 -08:00
echo $res->getHeaderLine('content-type');
2014-03-02 10:45:13 -08:00
// 'application/json; charset=utf8'
echo $res->getBody();
2016-11-15 18:51:04 +09:00
// '{"id": 1420053, "name": "guzzle", ...}'
2014-10-08 18:35:23 -07:00
// Send an asynchronous request.
2015-03-28 15:36:00 -07:00
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
$promise = $client->sendAsync($request)->then(function ($response) {
2015-06-30 09:15:07 -07:00
echo 'I completed! ' . $response->getBody();
2014-10-08 18:35:23 -07:00
});
2015-03-28 15:36:00 -07:00
$promise->wait();
2013-06-03 23:12:35 -07:00
```
2011-11-13 19:28:24 -06:00
2015-03-29 11:10:33 -07:00
## Help and docs
2014-03-02 10:45:13 -08:00
2015-03-29 11:10:33 -07:00
- [Documentation](http://guzzlephp.org/)
- [stackoverflow](http://stackoverflow.com/questions/tagged/guzzle)
- [Gitter](https://gitter.im/guzzle/guzzle)
2014-03-02 10:45:13 -08:00
2015-03-28 15:36:00 -07:00
2015-03-29 11:10:33 -07:00
## Installing Guzzle
2012-06-17 17:59:53 -07:00
2014-03-02 10:45:13 -08:00
The recommended way to install Guzzle is through
[Composer](http://getcomposer.org).
2012-06-17 17:59:53 -07:00
2013-06-03 23:12:35 -07:00
```bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
2014-03-15 16:46:57 -07:00
```
Next, run the Composer command to install the latest stable version of Guzzle:
2012-06-17 17:59:53 -07:00
```bash
php composer.phar require guzzlehttp/guzzle
2013-06-03 23:12:35 -07:00
```
2013-06-03 23:12:35 -07:00
After installing, you need to require Composer's autoloader:
2013-06-03 23:12:35 -07:00
```php
require 'vendor/autoload.php';
```
2015-03-29 11:10:33 -07:00
You can then later update Guzzle using composer:
2013-06-30 11:21:03 +01:00
2015-03-29 11:10:33 -07:00
```bash
composer.phar update
```
2015-05-26 11:22:06 -07:00
## Version Guidance
| Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version |
|---------|------------|---------------------|--------------|---------------------|---------------------|-------|-------------|
| 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >= 5.3.3 |
2016-11-15 11:43:43 +01:00
| 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >= 5.4 |
| 5.x | Maintained | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 |
| 6.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 |
2015-05-26 20:17:25 -07:00
2015-05-26 20:22:21 -07:00
[guzzle-3-repo]: https://github.com/guzzle/guzzle3
[guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x
2015-05-26 20:21:48 -07:00
[guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3
2015-05-26 20:17:25 -07:00
[guzzle-6-repo]: https://github.com/guzzle/guzzle
2015-05-26 20:21:48 -07:00
[guzzle-3-docs]: http://guzzle3.readthedocs.org/en/latest/
[guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/
[guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/