Skip to content

Commit 83e850e

Browse files
committed
updates UPGRADING to reflect guzzle 6 changes
1 parent 2e92c6d commit 83e850e

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

UPGRADING.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,12 @@ $client->getAuth()->sign($request);
179179
**After**
180180

181181
```php
182+
// create an authorized HTTP client
183+
$httpClient = $client->authorize();
184+
185+
// OR add authorization to an existing client
182186
$httpClient = new GuzzleHttp\Client();
183-
$client->authorize($httpClient);
187+
$httpClient = $client->authorize($httpClient);
184188
```
185189

186190
**Before**
@@ -193,12 +197,14 @@ $response = $client->getAuth()->authenticatedRequest($request);
193197
**After**
194198

195199
```php
196-
$httpClient = new GuzzleHttp\Client();
197-
$client->authorize($httpClient);
198-
$request = $httpClient->createRequest('POST', $url);
200+
$httpClient = $client->authorize();
201+
$request = new GuzzleHttp\Psr7\Request('POST', $url);
199202
$response = $httpClient->send($request);
200203
```
201204

205+
> NOTE: `$request` can be any class implementing
206+
> `Psr\Http\Message\RequestInterface`
207+
202208
In addition, other methods that were callable on `Google_Auth_OAuth2` are now called
203209
on the `Google_Client` object:
204210

@@ -225,18 +231,21 @@ $client->isAccessTokenExpired();
225231
This was previously `PHP 5.2`. If you still need to use PHP 5.2, please continue to use
226232
the [v1-master](https://github.com/google/google-api-php-client/tree/v1-master) branch.
227233

228-
## Guzzle 5 is used for HTTP Requests
234+
## Guzzle and PSR-7 are used for HTTP Requests
229235

230-
[`Guzzle 5`][Guzzle 5] is used for all HTTP Requests. As a result, all `Google_IO`-related
231-
functionality and `Google_Http`-related functionality has been changed or removed.
236+
The HTTP library Guzzle is used for all HTTP Requests. By default, [`Guzzle 6`][Guzzle 6]
237+
is used, but this library is also compatible with [`Guzzle 5`][Guzzle 5]. As a result,
238+
all `Google_IO`-related functionality and `Google_Http`-related functionality has been
239+
changed or removed.
232240

233241
1. Removed `Google_Http_Request`
234242
1. Removed `Google_IO_Abstract`, `Google_IO_Exception`, `Google_IO_Curl`, and `Google_IO_Stream`
235243
1. Removed methods `Google_Client::getIo` and `Google_Client::setIo`
236-
1. Refactored `Google_Http_Batch` and `Google_Http_MediaFileUpload` for Guzzle 5
237-
1. Added `Google_Http_Pool` for HTTP Pooling via Guzzle 5
244+
1. Refactored `Google_Http_Batch` and `Google_Http_MediaFileUpload` for Guzzle
238245
1. Added `Google_Client::getHttpClient` and `Google_Client::setHttpClient` for getting and
239-
setting the Guzzle 5 `GuzzleHttp\ClientInterface` object.
246+
setting the Guzzle `GuzzleHttp\ClientInterface` object.
247+
248+
> NOTE: `PSR-7`-compatible libraries can now be used with this library.
240249
241250
## Other Changes
242251

@@ -289,6 +298,7 @@ setting the Guzzle 5 `GuzzleHttp\ClientInterface` object.
289298

290299
[PSR 3]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
291300
[Guzzle 5]: https://github.com/guzzle/guzzle
301+
[Guzzle 6]: http://docs.guzzlephp.org/en/latest/psr7.html
292302
[Monolog]: https://github.com/Seldaek/monolog
293303
[Google Auth]: https://github.com/google/google-auth-library-php
294304
[Google Auth GCE]: https://github.com/google/google-auth-library-php/blob/master/src/GCECredentials.php

0 commit comments

Comments
 (0)