mirror of
https://github.com/guzzle/guzzle.git
synced 2025-03-14 19:29:49 +01:00
Guzzle 4.0!
This commit is contained in:
parent
dc841699e0
commit
4063f08ca4
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,6 +1,19 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.0.0 (2014-03-29)
|
||||
------------------
|
||||
|
||||
* For more information on the 4.0 transition, see:
|
||||
http://mtdowling.com/blog/2014/03/15/guzzle-4-rc/
|
||||
* For information on changes and upgrading, see:
|
||||
https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40
|
||||
* Added `GuzzleHttp\batch()` as a convenience function for sending requests in
|
||||
parallel without needing to write asynchronous code.
|
||||
* Restructured how events are added to `GuzzleHttp\ClientInterface::sendAll()`.
|
||||
You can now pass a callable or an array of associative arrays where each
|
||||
associative array contains the "fn", "priority", and "once" keys.
|
||||
|
||||
4.0.0.rc-2 (2014-03-25)
|
||||
-----------------------
|
||||
|
||||
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2011 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
|
||||
Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
4
Makefile
4
Makefile
@ -1,8 +1,5 @@
|
||||
all: clean coverage docs
|
||||
|
||||
list:
|
||||
@sh -c "$(MAKE) -p .dummy | awk -F':' '/^[a-zA-Z0-9][^\$$#\/\\t=]*:([^=]|$$)/ {split(\$$1,A,/ /);for(i in A)print A[i]}' | grep -v '__\$$' | sort"
|
||||
|
||||
start-server:
|
||||
@ps aux | grep 'node tests/server.js' | grep -v grep > /dev/null \
|
||||
|| node tests/server.js &> /dev/null &
|
||||
@ -38,4 +35,3 @@ perf: start-server
|
||||
$(MAKE) stop-server
|
||||
|
||||
.PHONY: docs
|
||||
.dummy:
|
||||
|
@ -51,7 +51,7 @@ Next, update your project's composer.json file to include Guzzle:
|
||||
```javascript
|
||||
{
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "4.0.*@RC"
|
||||
"guzzlehttp/guzzle": "~4.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
395
UPGRADING.md
395
UPGRADING.md
@ -8,55 +8,69 @@ Guzzle Upgrade Guide
|
||||
|
||||
- Now requires PHP 5.4 or greater.
|
||||
- No longer requires cURL to send requests.
|
||||
- Guzzle no longer wraps every exception it throws. Only exceptions that are recoverable are now wrapped by Guzzle.
|
||||
- Guzzle no longer wraps every exception it throws. Only exceptions that are
|
||||
recoverable are now wrapped by Guzzle.
|
||||
- Various namespaces have been removed or renamed.
|
||||
- No longer requiring the Symfony EventDispatcher. A custom event dispatcher based on the Symfony EventDispatcher is
|
||||
now utilized in `GuzzleHttp\Event\EmitterInterface` (resulting in significant speed and functionality improvements).
|
||||
- No longer requiring the Symfony EventDispatcher. A custom event dispatcher
|
||||
based on the Symfony EventDispatcher is
|
||||
now utilized in `GuzzleHttp\Event\EmitterInterface` (resulting in significant
|
||||
speed and functionality improvements).
|
||||
|
||||
Changes per Guzzle 3.x namespace are described below.
|
||||
|
||||
## Batch
|
||||
|
||||
The `Guzzle\Batch` namespace has been removed. This is best left to third-parties to implement on top of Guzzle's
|
||||
core HTTP library.
|
||||
The `Guzzle\Batch` namespace has been removed. This is best left to
|
||||
third-parties to implement on top of Guzzle's core HTTP library.
|
||||
|
||||
## Cache
|
||||
|
||||
The `Guzzle\Cache` namespace has been removed. (Todo: No suitable replacement has been implemented yet, but hoping to
|
||||
utilize a PSR cache interface).
|
||||
The `Guzzle\Cache` namespace has been removed. (Todo: No suitable replacement
|
||||
has been implemented yet, but hoping to utilize a PSR cache interface).
|
||||
|
||||
## Common
|
||||
|
||||
- Removed all of the wrapped exceptions. It's better to use the standard PHP library for unrecoverable exceptions.
|
||||
- Removed all of the wrapped exceptions. It's better to use the standard PHP
|
||||
library for unrecoverable exceptions.
|
||||
- `FromConfigInterface` has been removed.
|
||||
- `Guzzle\Common\Version` has been removed. The VERSION constant can be found at `GuzzleHttp\ClientInterface::VERSION`.
|
||||
- `Guzzle\Common\Version` has been removed. The VERSION constant can be found
|
||||
at `GuzzleHttp\ClientInterface::VERSION`.
|
||||
|
||||
### Collection
|
||||
|
||||
- `getAll` has been removed. Use `toArray` to convert a collection to an array.
|
||||
- `inject` has been removed.
|
||||
- `keySearch` has been removed.
|
||||
- `getPath` no longer supports wildcard expressions. Use something better like JMESPath for this.
|
||||
- `getPath` no longer supports wildcard expressions. Use something better like
|
||||
JMESPath for this.
|
||||
- `setPath` now supports appending to an existing array via the `[]` notation.
|
||||
|
||||
### Events
|
||||
|
||||
Guzzle no longer requires Symfony's EventDispatcher component. Guzzle now uses `GuzzleHttp\Event\Emitter`.
|
||||
Guzzle no longer requires Symfony's EventDispatcher component. Guzzle now uses
|
||||
`GuzzleHttp\Event\Emitter`.
|
||||
|
||||
- `Symfony\Component\EventDispatcher\EventDispatcherInterface` is replaced by `GuzzleHttp\Event\EmitterInterface`.
|
||||
- `Symfony\Component\EventDispatcher\EventDispatcher` is replaced by `GuzzleHttp\Event\Emitter`.
|
||||
- `Symfony\Component\EventDispatcher\Event` is replaced by `GuzzleHttp\Event\Event`, and Guzzle now has an EventInterface
|
||||
in `GuzzleHttp\Event\EventInterface`.
|
||||
- `AbstractHasDispatcher` has moved to a trait, `HasEmitterTrait`, and `HasDispatcherInterface` has moved to
|
||||
`HasEmitterInterface`. Retrieving the event emitter of a request, client, etc now uses the `getEmitter` method
|
||||
- `Symfony\Component\EventDispatcher\EventDispatcherInterface` is replaced by
|
||||
`GuzzleHttp\Event\EmitterInterface`.
|
||||
- `Symfony\Component\EventDispatcher\EventDispatcher` is replaced by
|
||||
`GuzzleHttp\Event\Emitter`.
|
||||
- `Symfony\Component\EventDispatcher\Event` is replaced by
|
||||
`GuzzleHttp\Event\Event`, and Guzzle now has an EventInterface in
|
||||
`GuzzleHttp\Event\EventInterface`.
|
||||
- `AbstractHasDispatcher` has moved to a trait, `HasEmitterTrait`, and
|
||||
`HasDispatcherInterface` has moved to `HasEmitterInterface`. Retrieving the
|
||||
event emitter of a request, client, etc now uses the `getEmitter` method
|
||||
rather than the `getDispatcher` method.
|
||||
|
||||
#### Emitter
|
||||
|
||||
- Use the `once()` method to add a listener that automatically removes itself the first time it is invoked.
|
||||
- Use the `listeners` method to retrieve a list of event listeners rather than the `getListeners` method.
|
||||
- Use `emit` instead of `dispatch` to emit an event from an emitter.
|
||||
- Use `attach` instead of `addSubscriber` and `detach` instead of `removeSubscriber`.
|
||||
- Use the `once()` method to add a listener that automatically removes itself
|
||||
the first time it is invoked.
|
||||
- Use the `listeners()` method to retrieve a list of event listeners rather than
|
||||
the `getListeners()` method.
|
||||
- Use `emit()` instead of `dispatch()` to emit an event from an emitter.
|
||||
- Use `attach()` instead of `addSubscriber()` and `detach()` instead of
|
||||
`removeSubscriber()`.
|
||||
|
||||
```php
|
||||
$mock = new Mock();
|
||||
@ -68,7 +82,7 @@ $request->getEmitter()->attach($mock);
|
||||
$request->getEmitter()->detach($mock);
|
||||
```
|
||||
|
||||
Use the `on()` method to add a listener rather than the `addListener` method.
|
||||
Use the `on()` method to add a listener rather than the `addListener()` method.
|
||||
|
||||
```php
|
||||
// 3.x
|
||||
@ -81,23 +95,27 @@ $request->getEmitter()->on('foo', function (Event $event, $name) { /* ... */ } )
|
||||
|
||||
### General changes
|
||||
|
||||
- The cacert.pem certificate has been moved to `src/Guzzle/Http/cacert.pem`.
|
||||
- Added the concept of adapters that are used to transfer requests over the wire.
|
||||
- The cacert.pem certificate has been moved to `src/cacert.pem`.
|
||||
- Added the concept of adapters that are used to transfer requests over the
|
||||
wire.
|
||||
- Simplified the event system.
|
||||
- Sending requests in parallel is still possible, but batching is no longer a concept of the HTTP layer. Instead,
|
||||
you must use the `request.after_send` and `error` events to manage parallel request transfers.
|
||||
- Sending requests in parallel is still possible, but batching is no longer a
|
||||
concept of the HTTP layer. Instead, you must use the `complete` and `error`
|
||||
events to asynchronously manage parallel request transfers.
|
||||
- `Guzzle\Http\Url` has moved to `GuzzleHttp\Url`.
|
||||
- `Guzzle\Http\QueryString` has moved to `GuzzleHttp\Query`.
|
||||
- QueryAggregator classes have moved to `GuzzleHttp\Url`.
|
||||
- QueryAggregators now accept only an array with any amount of nesting and returns a flattened array.
|
||||
- `GuzzleHttp\StaticClient` has been removed. Use the functions provided in `functions.php` for an easy to use static
|
||||
client instance.
|
||||
- Exceptions in `GuzzleHttp\Exception` have been updated to all extend from `GuzzleHttp\Exception\TransferException`.
|
||||
- QueryAggregators have been rewritten so that they are simply callable
|
||||
functions.
|
||||
- `GuzzleHttp\StaticClient` has been removed. Use the functions provided in
|
||||
`functions.php` for an easy to use static client instance.
|
||||
- Exceptions in `GuzzleHttp\Exception` have been updated to all extend from
|
||||
`GuzzleHttp\Exception\TransferException`.
|
||||
|
||||
### Client
|
||||
|
||||
Calling methods like `get()`, `post()`, `head()`, etc. no longer create and return a request, but rather create a
|
||||
request, send the request, and returns the response.
|
||||
Calling methods like `get()`, `post()`, `head()`, etc. no longer create and
|
||||
return a request, but rather creates a request, sends the request, and returns
|
||||
the response.
|
||||
|
||||
```php
|
||||
// 3.0
|
||||
@ -114,48 +132,56 @@ $response = $client->send($request);
|
||||
|
||||
`GuzzleHttp\ClientInterface` has changed.
|
||||
|
||||
- `getConfig()` will never return a Collection object. Use `getConfig()` and a JSON pointer type syntax to retrieve
|
||||
nested values from the client configuration data. Note: JSON pointer escaping is not supported.
|
||||
- `setConfig()` can no longer change the `GuzzleHttp\Collection` instance used by the client, but will only
|
||||
change the actual values stored in the client's `Collection` instance.
|
||||
- The `send` method no longer accepts more than one request. Use `sendAll` to send multiple requests in parallel.
|
||||
- `getBaseUrl()` has been removed. Use `$client->getConfig('base_url')` instead.
|
||||
- `setUserAgent()` has been removed. Use a default request option instead. You could, for example, do something
|
||||
like: `$client->setConfig('defaults/headers/User-Agent', 'Foo/Bar ' . $client::getDefaultUserAgent())`.
|
||||
- `setSslVerification()` has been removed. Use default request options instead, like
|
||||
`$client->setConfig('defaults/verify', true)`.
|
||||
- The `send` method no longer accepts more than one request. Use `sendAll` to
|
||||
send multiple requests in parallel.
|
||||
- `setUserAgent()` has been removed. Use a default request option instead. You
|
||||
could, for example, do something like:
|
||||
`$client->setConfig('defaults/headers/User-Agent', 'Foo/Bar ' . $client::getDefaultUserAgent())`.
|
||||
- `setSslVerification()` has been removed. Use default request options instead,
|
||||
like `$client->setConfig('defaults/verify', true)`.
|
||||
|
||||
`GuzzleHttp\Client` has changed.
|
||||
|
||||
- The constructor now accepts only an associative array. You can include a `base_url` string or array to use a
|
||||
URI template as the base URL of a client. You can also specify a `defaults` key that is an associative array of
|
||||
default request options. You can pass an `adapter` to use a custom adapter, `batch_adapter` to use a custom
|
||||
adapter for sending requests in parallel, or a `message_factory` to change the factory used to create HTTP
|
||||
requests and responses.
|
||||
- The constructor now accepts only an associative array. You can include a
|
||||
`base_url` string or array to use a URI template as the base URL of a client.
|
||||
You can also specify a `defaults` key that is an associative array of default
|
||||
request options. You can pass an `adapter` to use a custom adapter,
|
||||
`batch_adapter` to use a custom adapter for sending requests in parallel, or
|
||||
a `message_factory` to change the factory used to create HTTP requests and
|
||||
responses.
|
||||
- The client no longer emits a `client.create_request` event.
|
||||
- Creating requests with a client no longer automatically utilize a URI template. You must pass an array into a
|
||||
creational method (e.g., `createRequest`, `get`, `put`, etc...) in order to expand a URI template.
|
||||
- Creating requests with a client no longer automatically utilize a URI
|
||||
template. You must pass an array into a creational method (e.g.,
|
||||
`createRequest`, `get`, `put`, etc...) in order to expand a URI template.
|
||||
|
||||
### Messages
|
||||
|
||||
Messages no longer have references to their counterparts (i.e., a request no longer has a reference to it's response,
|
||||
and a response no longer has a reference to its request). This association is now managed thorugh a
|
||||
`GuzzleHttp\Adapter\TransactionInterface` object. You can get references to these transaction objects using request
|
||||
events that are emitted over the lifecycle of a request.
|
||||
Messages no longer have references to their counterparts (i.e., a request no
|
||||
longer has a reference to it's response, and a response no loger has a
|
||||
reference to its request). This association is now managed through a
|
||||
`GuzzleHttp\Adapter\TransactionInterface` object. You can get references to
|
||||
these transaction objects using request events that are emitted over the
|
||||
lifecycle of a request.
|
||||
|
||||
#### Requests with a body
|
||||
|
||||
- `GuzzleHttp\Message\EntityEnclosingRequest` and `GuzzleHttp\Message\EntityEnclosingRequestInterface` have been
|
||||
removed. The separation between requests that contain a body and requests that do not contain a body has been removed,
|
||||
and now `GuzzleHttp\Message\RequestInterface` handles both use cases.
|
||||
- `GuzzleHttp\Message\EntityEnclosingRequest` and
|
||||
`GuzzleHttp\Message\EntityEnclosingRequestInterface` have been removed. The
|
||||
separation between requests that contain a body and requests that do not
|
||||
contain a body has been removed, and now `GuzzleHttp\Message\RequestInterface`
|
||||
handles both use cases.
|
||||
- Any method that previously accepts a `GuzzleHttp\Response` object now accept a
|
||||
`GuzzleHttp\Message\ResponseInterface`.
|
||||
- `GuzzleHttp\Message\RequestFactoryInterface` has been renamed to `GuzzleHttp\Message\MessageFactoryInterface`. This
|
||||
interface is used to create both requests and responses and is implemented in `GuzzleHttp\Message\MessageFactory`.
|
||||
- POST field and file methods have been removed from the request object. You must now use the methods made available to
|
||||
`GuzzleHttp\Post\PostBodyInterface` to control the format of a POST body. Requests that are created using
|
||||
a standard `GuzzleHttp\Message\MessageFactoryInterface` will automatically use a `GuzzleHttp\Post\PostBody`
|
||||
body if the body was passed as an array or if the method is POST and no body is provided.
|
||||
- `GuzzleHttp\Message\RequestFactoryInterface` has been renamed to
|
||||
`GuzzleHttp\Message\MessageFactoryInterface`. This interface is used to create
|
||||
both requests and responses and is implemented in
|
||||
`GuzzleHttp\Message\MessageFactory`.
|
||||
- POST field and file methods have been removed from the request object. You
|
||||
must now use the methods made available to `GuzzleHttp\Post\PostBodyInterface`
|
||||
to control the format of a POST body. Requests that are created using a
|
||||
standard `GuzzleHttp\Message\MessageFactoryInterface` will automatically use
|
||||
a `GuzzleHttp\Post\PostBody` body if the body was passed as an array or if
|
||||
the method is POST and no body is provided.
|
||||
|
||||
```php
|
||||
$request = $client->createRequest('POST', '/');
|
||||
@ -165,35 +191,44 @@ $request->getBody()->addFile(new PostFile('file_key', fopen('/path/to/content',
|
||||
|
||||
#### Headers
|
||||
|
||||
- `GuzzleHttp\Message\Header` has been moved to `GuzzleHttp\Message\HeaderValues`, and the interface has changed to
|
||||
now use `\ArrayAccess` methods like `offsetGet` and `offsetSet`.
|
||||
- `GuzzleHttp\Message\Header` has been removed. Header values are now simply
|
||||
represented by an array of values or as a string. Header values are returned
|
||||
as a string by default when retrieving a header value from a message. You can
|
||||
pass an optional argument of `true` to retrieve a header value as an array
|
||||
of strings instead of a single concatenated string.
|
||||
- `GuzzleHttp\PostFile` and `GuzzleHttp\PostFileInterface` have been moved to
|
||||
`GuzzleHttp\Post`. This interface has been simplified and now allows the addition of arbitrary headers via
|
||||
the `GuzzleHttp\Message\HasHeadersInterface` interface.
|
||||
- Custom headers like `GuzzleHttp\Message\Header\Link` have been removed. Most of the custom headers are now handled
|
||||
separately in specific subscribers/plugins, and `GuzzleHttp\Message\HeaderValues::parseParams()` has been updated to
|
||||
properly handle headers that contain parameters (like the `Link` header).
|
||||
`GuzzleHttp\Post`. This interface has been simplified and now allows the
|
||||
addition of arbitrary headers.
|
||||
- Custom headers like `GuzzleHttp\Message\Header\Link` have been removed. Most
|
||||
of the custom headers are now handled separately in specific
|
||||
subscribers/plugins, and `GuzzleHttp\Message\HeaderValues::parseParams()` has
|
||||
been updated to properly handle headers that contain parameters (like the
|
||||
`Link` header).
|
||||
|
||||
#### Responses
|
||||
|
||||
- `GuzzleHttp\Message\Response::getInfo()` and `GuzzleHttp\Message\Response::setInfo()` have been removed. Use the
|
||||
event system to retrieve this type of information.
|
||||
- `GuzzleHttp\Message\Response::getInfo()` and
|
||||
`GuzzleHttp\Message\Response::setInfo()` have been removed. Use the event
|
||||
system to retrieve this type of information.
|
||||
- `GuzzleHttp\Message\Response::getRawHeaders()` has been removed.
|
||||
- `GuzzleHttp\Message\Response::getMessage()` has been removed.
|
||||
- `GuzzleHttp\Message\Response::calculateAge()` and other cache specific methods have moved to the CacheSubscriber.
|
||||
- Allow of the header specific helper functions like `getContentMd5()` have been removed. Just use
|
||||
`getHeader('Content-MD5')` instead.
|
||||
- `GuzzleHttp\Message\Response::setRequest()` and `GuzzleHttp\Message\Response::getRequest()` have been removed.
|
||||
Use the associated `GuzzleHttp\Adapter\TransactionInterface` object to get the association between a request and
|
||||
response.
|
||||
- `GuzzleHttp\Message\Response::getRedirectCount()` has been removed. Use the Redirect subscriber instead.
|
||||
- `GuzzleHttp\Message\Response::isSuccessful()` and other related methods have been removed. Use `getStatusCode()`
|
||||
instead.
|
||||
- `GuzzleHttp\Message\Response::calculateAge()` and other cache specific
|
||||
methods have moved to the CacheSubscriber.
|
||||
- Header specific helper functions like `getContentMd5()` have been removed.
|
||||
Just use `getHeader('Content-MD5')` instead.
|
||||
- `GuzzleHttp\Message\Response::setRequest()` and
|
||||
`GuzzleHttp\Message\Response::getRequest()` have been removed. Use the event
|
||||
system to work with request and response objects as a transaction.
|
||||
- `GuzzleHttp\Message\Response::getRedirectCount()` has been removed. Use the
|
||||
Redirect subscriber instead.
|
||||
- `GuzzleHttp\Message\Response::isSuccessful()` and other related methods have
|
||||
been removed. Use `getStatusCode()` instead.
|
||||
|
||||
#### Streaming responses
|
||||
|
||||
Streaming requests can now be created by a client directly, returning a `GuzzleHttp\Message\ResponseInterface` object
|
||||
that contains a body stream referencing an open PHP HTTP stream.
|
||||
Streaming requests can now be created by a client directly, returning a
|
||||
`GuzzleHttp\Message\ResponseInterface` object that contains a body stream
|
||||
referencing an open PHP HTTP stream.
|
||||
|
||||
```php
|
||||
// 3.0
|
||||
@ -211,7 +246,8 @@ $data = $response->getBody()->read(1024);
|
||||
|
||||
#### Redirects
|
||||
|
||||
The `configureRedirects()` method has been removed in favor of a `allow_redirects` request option.
|
||||
The `configureRedirects()` method has been removed in favor of a
|
||||
`allow_redirects` request option.
|
||||
|
||||
```php
|
||||
// Standard redirects with a default of a max of 5 redirects
|
||||
@ -225,9 +261,13 @@ $request = $client->createRequest('GET', '/', [
|
||||
|
||||
#### EntityBody
|
||||
|
||||
EntityBody interfaces and classes have been removed or moved to `GuzzleHttp\Stream`. All classes and interfaces that once
|
||||
required `GuzzleHttp\EntityBodyInterface` now require `GuzzleHttp\Stream\StreamInterface`. Creating a new body for a
|
||||
request no longer uses `GuzzleHttp\EntityBody::factory` but now uses `GuzzleHttp\Stream\Stream::factory`.
|
||||
EntityBody interfaces and classes have been removed or moved to
|
||||
`GuzzleHttp\Stream`. All classes and interfaces that once required
|
||||
`GuzzleHttp\EntityBodyInterface` now require
|
||||
`GuzzleHttp\Stream\StreamInterface`. Creating a new body for a request no
|
||||
longer uses `GuzzleHttp\EntityBody::factory` but now uses
|
||||
`GuzzleHttp\Stream\Stream::factory` or even better:
|
||||
`GuzzleHttp\Stream\create()`.
|
||||
|
||||
- `Guzzle\Http\EntityBodyInterface` is now `GuzzleHttp\Stream\StreamInterface`
|
||||
- `Guzzle\Http\EntityBody` is now `GuzzleHttp\Stream\Stream`
|
||||
@ -237,110 +277,156 @@ request no longer uses `GuzzleHttp\EntityBody::factory` but now uses `GuzzleHttp
|
||||
|
||||
#### Request lifecycle events
|
||||
|
||||
Requests previously submitted a large number of requests. The number of events emitted over the lifecycle of a request
|
||||
has been significantly reduced to make it easier to understand how to extend the behavior of a request. All events
|
||||
emitted during the lifecycle of a request now emit a custom `GuzzleHttp\Event\EventInterface` object that contains
|
||||
context providing methods and a way in which to modify the transaction at that specific point in time (e.g., intercept
|
||||
the request and set a response on the transaction).
|
||||
Requests previously submitted a large number of requests. The number of events
|
||||
emitted over the lifecycle of a request has been significantly reduced to make
|
||||
it easier to understand how to extend the behavior of a request. All events
|
||||
emitted during the lifecycle of a request now emit a custom
|
||||
`GuzzleHttp\Event\EventInterface` object that contains context providing
|
||||
methods and a way in which to modify the transaction at that specific point in
|
||||
time (e.g., intercept the request and set a response on the transaction).
|
||||
|
||||
- `request.before_send` has been renamed to ``before`` and now emits a `GuzzleHttp\Event\BeforeEvent`
|
||||
- `request.complete` has been renamed to `complete` and now emits a `GuzzleHttp\Event\CompleteEvent`.
|
||||
- `request.sent` has been removed.
|
||||
- `request.success` has been removed.
|
||||
- `request.before_send` has been renamed to ``before`` and now emits a
|
||||
`GuzzleHttp\Event\BeforeEvent`
|
||||
- `request.complete` has been renamed to `complete` and now emits a
|
||||
`GuzzleHttp\Event\CompleteEvent`.
|
||||
- `request.sent` has been removed. Use `complete`.
|
||||
- `request.success` has been removed. Use `complete`.
|
||||
- `error` is now an event that emits a `GuzzleHttp\Event\ErrorEvent`.
|
||||
- `request.exception` has been removed.
|
||||
- `request.exception` has been removed. Use `error`.
|
||||
- `request.receive.status_line` has been removed.
|
||||
- `curl.callback.progress` has been removed. Use a custom `StreamInterface` to maintain a status update.
|
||||
- `curl.callback.write` has been removed. Use a custom `StreamInterface` to intercept writes.
|
||||
- `curl.callback.read` has been removed. Use a custom `StreamInterface` to intercept reads.
|
||||
- `curl.callback.progress` has been removed. Use a custom `StreamInterface` to
|
||||
maintain a status update.
|
||||
- `curl.callback.write` has been removed. Use a custom `StreamInterface` to
|
||||
intercept writes.
|
||||
- `curl.callback.read` has been removed. Use a custom `StreamInterface` to
|
||||
intercept reads.
|
||||
|
||||
`headers` is a new event that is emitted after the response headers of a request have been received
|
||||
before the body of the response is downloaded. This event emits a `GuzzleHttp\Event\HeadersEvent`.
|
||||
`headers` is a new event that is emitted after the response headers of a
|
||||
request have been received before the body of the response is downloaded. This
|
||||
event emits a `GuzzleHttp\Event\HeadersEvent`.
|
||||
|
||||
You can intercept a request and inject a response using the `intercept()` event of a
|
||||
`GuzzleHttp\Event\BeforeEvent`, `GuzzleHttp\Event\CompleteEvent`, and
|
||||
You can intercept a request and inject a response using the `intercept()` event
|
||||
of a `GuzzleHttp\Event\BeforeEvent`, `GuzzleHttp\Event\CompleteEvent`, and
|
||||
`GuzzleHttp\Event\ErrorEvent` event.
|
||||
|
||||
See: http://docs.guzzlephp.org/en/latest/events.html
|
||||
|
||||
## Inflection
|
||||
|
||||
The `Guzzle\Inflection` namespace has been removed. This is not a core concern of Guzzle.
|
||||
The `Guzzle\Inflection` namespace has been removed. This is not a core concern
|
||||
of Guzzle.
|
||||
|
||||
## Iterator
|
||||
|
||||
The `Guzzle\Iterator` namespace has been removed.
|
||||
|
||||
- `Guzzle\Iterator\AppendIterator`, `Guzzle\Iterator\ChunkedIterator`, and `Guzzle\Iterator\MethodProxyIterator` are
|
||||
nice, but not a core requirement of Guzzle itself.
|
||||
- `Guzzle\Iterator\FilterIterator` is no longer needed because an equivalent class is shipped with PHP 5.4.
|
||||
- `Guzzle\Iterator\MapIterator` is not really needed when using PHP 5.5 because it's easier to just wrap an iterator
|
||||
in a generator that maps values.
|
||||
- `Guzzle\Iterator\AppendIterator`, `Guzzle\Iterator\ChunkedIterator`, and
|
||||
`Guzzle\Iterator\MethodProxyIterator` are nice, but not a core requirement of
|
||||
Guzzle itself.
|
||||
- `Guzzle\Iterator\FilterIterator` is no longer needed because an equivalent
|
||||
class is shipped with PHP 5.4.
|
||||
- `Guzzle\Iterator\MapIterator` is not really needed when using PHP 5.5 because
|
||||
it's easier to just wrap an iterator in a generator that maps values.
|
||||
|
||||
For a replacement of these iterators, see https://github.com/nikic/iter
|
||||
|
||||
## Log
|
||||
|
||||
The `Guzzle\Log` namespace has been removed. Guzzle now relies on `Psr\Log\LoggerInterface` for all logging.
|
||||
The MessageFormatter class has been moved to `GuzzleHttp\Subscriber\Log\MessageFormatter`.
|
||||
The LogPlugin has moved to https://github.com/guzzle/log-subscriber. The
|
||||
`Guzzle\Log` namespace has been removed. Guzzle now relies on
|
||||
`Psr\Log\LoggerInterface` for all logging. The MessageFormatter class has been
|
||||
moved to `GuzzleHttp\Subscriber\Log\Formatter`.
|
||||
|
||||
## Parser
|
||||
|
||||
The `Guzzle\Parser` namespace has been removed. This was previously used to parse cookies, messages, URI templates,
|
||||
and URLs.
|
||||
The `Guzzle\Parser` namespace has been removed. This was previously used to
|
||||
make it possible to plug in custom parsers for cookies, messages, URI
|
||||
templates, and URLs; however, this level of complexity is not needed in Guzzle
|
||||
so it has been removed.
|
||||
|
||||
- Cookie: Cookie parsing logic has been moved to `GuzzleHttp\Subscriber\CookieJar\SetCookie::fromString`. Extending
|
||||
cookie parsing is no longer possible (and was never really needed).
|
||||
- Message: Message parsing logic for both requests and responses has been moved to
|
||||
`GuzzleHttp\Message\MessageFactory::fromMessage`. Message parsing is only used in debugging or deserializing
|
||||
messages, so it doesn't make sense for Guzzle as a library to add this level of complexity to parsing messages.
|
||||
- UriTemplate: URI template parsing has been moved to `GuzzleHttp\Url\UriTemplate`. The Guzzle library will automatically
|
||||
use the PECL URI template library if it is installed.
|
||||
- Url: URL parsing is now performed in `GuzzleHttp\Url::fromString`. If custom URL parsing is necessary, then
|
||||
developers are free to subclass `GuzzleHttp\Url`.
|
||||
- Cookie: Cookie parsing logic has been moved to
|
||||
`GuzzleHttp\Cookie\SetCookie::fromString`.
|
||||
- Message: Message parsing logic for both requests and responses has been moved
|
||||
to `GuzzleHttp\Message\MessageFactory::fromMessage`. Message parsing is only
|
||||
used in debugging or deserializing messages, so it doesn't make sense for
|
||||
Guzzle as a library to add this level of complexity to parsing messages.
|
||||
- UriTemplate: URI template parsing has been moved to
|
||||
`GuzzleHttp\UriTemplate`. The Guzzle library will automatically use the PECL
|
||||
URI template library if it is installed.
|
||||
- Url: URL parsing is now performed in `GuzzleHttp\Url::fromString` (previously
|
||||
it was `Guzzle\Http\Url::factory()`). If custom URL parsing is necessary,
|
||||
then developers are free to subclass `GuzzleHttp\Url`.
|
||||
|
||||
## Plugin
|
||||
|
||||
The `Guzzle\Plugin` namespace has been renamed to `GuzzleHttp\Subscriber`. Several plugins are shipping with the core
|
||||
Guzzle library under this namespace.
|
||||
The `Guzzle\Plugin` namespace has been renamed to `GuzzleHttp\Subscriber`.
|
||||
Several plugins are shipping with the core Guzzle library under this namespace.
|
||||
|
||||
- `GuzzleHttp\Subscriber\Cookie`: Replaces the old CookiePlugin. Cookie jar code has moved to
|
||||
`GuzzleHttp\CookieJar`.
|
||||
- `GuzzleHttp\Subscriber\Cookie`: Replaces the old CookiePlugin. Cookie jar
|
||||
code has moved to `GuzzleHttp\Cookie`.
|
||||
- `GuzzleHttp\Subscriber\History`: Replaces the old HistoryPlugin.
|
||||
- `GuzzleHttp\Subscriber\HttpError`: Throws errors when a bad HTTP response is received.
|
||||
- `GuzzleHttp\Subscriber\HttpError`: Throws errors when a bad HTTP response is
|
||||
received.
|
||||
- `GuzzleHttp\Subscriber\Mock`: Replaces the old MockPlugin.
|
||||
- `GuzzleHttp\Subscriber\Prepare`: Prepares the body of a request just before sending.
|
||||
- `GuzzleHttp\Subscriber\Prepare`: Prepares the body of a request just before
|
||||
sending. This subscriber is attached to all requests by default.
|
||||
- `GuzzleHttp\Subscriber\Redirect`: Replaces the RedirectPlugin.
|
||||
|
||||
The following plugins have been removed (third-parties are free to re-implement these if needed):
|
||||
The following plugins have been removed (third-parties are free to re-implement
|
||||
these if needed):
|
||||
|
||||
- `GuzzleHttp\Plugin\Async` has been removed.
|
||||
- `GuzzleHttp\Plugin\CurlAuth` has been removed.
|
||||
- `GuzzleHttp\Plugin\ErrorResponse\ErrorResponsePlugin` has been removed.
|
||||
- `GuzzleHttp\Plugin\ErrorResponse\ErrorResponsePlugin` has been removed. This
|
||||
functionality should instead be implemented with event listeners that occur
|
||||
after normal response parsing occurs in the guzzle/command package.
|
||||
|
||||
The following plugins are not part of the core Guzzle package, but are provided in separate repositories:
|
||||
The following plugins are not part of the core Guzzle package, but are provided
|
||||
in separate repositories:
|
||||
|
||||
- `Guzzle\Http\Plugin\BackoffPlugin` has been renamed to `GuzzleHttp\Subscriber\Retry`. This plugin has been rewritten to be
|
||||
much simpler to build custom retry policies using simple functions rather than various chained classes.
|
||||
- `Guzzle\Http\Plugin\Cache\CachePlugin` has moved to `GuzzleHttp\Subscriber\Cache\CacheSubscriber`.
|
||||
- `Guzzle\Http\Plugin\Log\LogPlugin` has moved to `GuzzleHttp\Subscriber\Log\LogSubscriber`.
|
||||
- `Guzzle\Http\Plugin\Md5\Md5Plugin` has moved to `GuzzleHttp\Subscriber\MessageIntegrity\MessageIntegritySubscriber`.
|
||||
- `Guzzle\Http\Plugin\Mock\MockPlugin` has moved to `GuzzleHttp\Subscriber\Mock\MockSubscriber`.
|
||||
- `Guzzle\Http\Plugin\Oauth\OauthPlugin` has moved to `GuzzleHttp\Subscriber\Oauth\OauthSubscriber`.
|
||||
- `Guzzle\Http\Plugin\BackoffPlugin` has been rewritten to be muchs simpler
|
||||
to build custom retry policies using simple functions rather than various
|
||||
chained classes. See: https://github.com/guzzle/retry-subscriber
|
||||
- `Guzzle\Http\Plugin\Cache\CachePlugin` has moved to
|
||||
https://github.com/guzzle/cache-subscriber
|
||||
- `Guzzle\Http\Plugin\Log\LogPlugin` has moved to
|
||||
https://github.com/guzzle/log-subscriber
|
||||
- `Guzzle\Http\Plugin\Md5\Md5Plugin` has moved to
|
||||
https://github.com/guzzle/message-integrity-subscriber
|
||||
- `Guzzle\Http\Plugin\Mock\MockPlugin` has moved to
|
||||
`GuzzleHttp\Subscriber\MockSubscriber`.
|
||||
- `Guzzle\Http\Plugin\Oauth\OauthPlugin` has moved to
|
||||
https://github.com/guzzle/oauth-subscriber
|
||||
|
||||
## Service
|
||||
|
||||
TODO
|
||||
The service description layer of Guzzle has moved into two separate packages:
|
||||
|
||||
- http://github.com/guzzle/command Provides a high level abstraction over web
|
||||
services by representing web service operations using commands.
|
||||
- http://github.com/guzzle/guzzle-services Provides an implementation of
|
||||
guzzle/command that provides request serialization and response parsing using
|
||||
Guzzle service descriptions.
|
||||
|
||||
## Stream
|
||||
|
||||
`Guzzle\Stream\StreamInterface` has been given a large update to cleanly take on the responsibilities of
|
||||
`Guzzle\Http\EntityBody` and `Guzzle\Http\EntityBodyInterface` now that they have been removed. The number of methods
|
||||
implemented by the `StreamInterface` has been drastically reduced to allow developers to more easily extend and
|
||||
decorate stream behavior.
|
||||
Stream have moved to a separate package available at
|
||||
https://github.com/guzzle/streams.
|
||||
|
||||
`Guzzle\Stream\StreamInterface` has been given a large update to cleanly take
|
||||
on the responsibilities of `Guzzle\Http\EntityBody` and
|
||||
`Guzzle\Http\EntityBodyInterface` now that they have been removed. The number
|
||||
of methods implemented by the `StreamInterface` has been drastically reduced to
|
||||
allow developers to more easily extend and decorate stream behavior.
|
||||
|
||||
## Removed methods from StreamInterface
|
||||
|
||||
- `getStream` and `setStream` have been removed to better encapsulate streams.
|
||||
- `getMetadata` and `setMetadata` have been removed in favor of `GuzzleHttp\Stream\MetadataStreamInterface`.
|
||||
- `getWrapper`, `getWrapperData`, `getStreamType`, and `getUri` have all been removed. This data is accessible when
|
||||
using streams that implement `GuzzleHttp\Stream\MetadataStreamInterface`.
|
||||
- `getMetadata` and `setMetadata` have been removed in favor of
|
||||
`GuzzleHttp\Stream\MetadataStreamInterface`.
|
||||
- `getWrapper`, `getWrapperData`, `getStreamType`, and `getUri` have all been
|
||||
removed. This data is accessible when
|
||||
using streams that implement `GuzzleHttp\Stream\MetadataStreamInterface`.
|
||||
- `rewind` has been removed. Use `seek(0)` for a similar behavior.
|
||||
|
||||
## Renamed methods
|
||||
@ -348,18 +434,21 @@ decorate stream behavior.
|
||||
- `detachStream` has been renamed to `detach`.
|
||||
- `feof` has been renamed to `eof`.
|
||||
- `ftell` has been renamed to `tell`.
|
||||
- `readLine` has moved from an instance method to a static class method of `GuzzleHttp\Stream\Stream`.
|
||||
- `readLine` has moved from an instance method to a static class method of
|
||||
`GuzzleHttp\Stream\Stream`.
|
||||
|
||||
## Metadata streams
|
||||
|
||||
`GuzzleHttp\Stream\MetadataStreamInterface` has been added to denote streams that contain additonal metadata accessible
|
||||
via `getMetadata()`. `GuzzleHttp\Stream\StreamInterface::getMetadata` and `GuzzleHttp\Stream\StreamInterface::setMetadata`
|
||||
have been removed.
|
||||
`GuzzleHttp\Stream\MetadataStreamInterface` has been added to denote streams
|
||||
that contain additonal metadata accessible via `getMetadata()`.
|
||||
`GuzzleHttp\Stream\StreamInterface::getMetadata` and
|
||||
`GuzzleHttp\Stream\StreamInterface::setMetadata` have been removed.
|
||||
|
||||
## SteamRequestFactory
|
||||
|
||||
The entire concept of the StreamRequestFactory has been removed. The way this was used in Guzzle 3 broke the actual
|
||||
interface of sending streaming requests (instead of getting back a Response, you got a StreamInterface). Streeaming
|
||||
The entire concept of the StreamRequestFactory has been removed. The way this
|
||||
was used in Guzzle 3 broke the actual interface of sending streaming requests
|
||||
(instead of getting back a Response, you got a StreamInterface). Streeaming
|
||||
PHP requests are now implemented throught the `GuzzleHttp\Adapter\StreamAdapter`.
|
||||
|
||||
3.6 to 3.7
|
||||
|
@ -92,12 +92,3 @@ of a web service.
|
||||
Provides an implementation of the *Guzzle Command* library that uses
|
||||
Guzzle service descriptions to describe web services, serialize requests,
|
||||
and parse responses into easy to use model structures.
|
||||
|
||||
API Documentation
|
||||
-----------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
api
|
||||
migrating-to-4
|
||||
|
@ -1,5 +0,0 @@
|
||||
================
|
||||
Migrating to 4.0
|
||||
================
|
||||
|
||||
WIP
|
@ -43,7 +43,6 @@ existing composer.json file:
|
||||
.. code-block:: js
|
||||
|
||||
{
|
||||
"minimum-stability": "RC",
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "4.*"
|
||||
}
|
||||
@ -55,14 +54,14 @@ After installing, you need to require Composer's autoloader:
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
You can find out more on how to install Composer, configure autoloading, and other best-practices for defining
|
||||
dependencies at `getcomposer.org <http://getcomposer.org>`_.
|
||||
You can find out more on how to install Composer, configure autoloading, and
|
||||
other best-practices for defining dependencies at `getcomposer.org <http://getcomposer.org>`_.
|
||||
|
||||
Bleeding edge
|
||||
-------------
|
||||
|
||||
During your development, you can keep up with the latest changes on the master branch by setting the version
|
||||
requirement for Guzzle to ``dev-master``.
|
||||
During your development, you can keep up with the latest changes on the master
|
||||
branch by setting the version requirement for Guzzle to ``dev-master``.
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
|
@ -13,7 +13,7 @@ use GuzzleHttp\Exception\AdapterException;
|
||||
*/
|
||||
interface ClientInterface extends HasEmitterInterface
|
||||
{
|
||||
const VERSION = '4.0.0.rc-2';
|
||||
const VERSION = '4.0.0';
|
||||
|
||||
/**
|
||||
* Create and return a new {@see RequestInterface} object.
|
||||
|
Loading…
x
Reference in New Issue
Block a user