Skip to content

5.0.0 release

Compare
Choose a tag to compare
@mtdowling mtdowling released this 13 Oct 03:22
· 1272 commits to 7.9 since this release

Adding support for non-blocking responses and some minor API cleanup.

New Features

  • Added support for non-blocking responses based on guzzlehttp/guzzle-ring.
  • Added a public API for creating a default HTTP adapter.
  • Updated the redirect plugin to be non-blocking so that redirects are sent
    concurrently. Other plugins like this can now be updated to be non-blocking.
  • Added a "progress" event so that you can get upload and download progress
    events.
  • Added GuzzleHttp\Pool which implements FutureInterface and transfers
    requests concurrently using a capped pool size as efficiently as possible.
  • Added hasListeners() to EmitterInterface.
  • Removed GuzzleHttp\ClientInterface::sendAll and marked
    GuzzleHttp\Client::sendAll as deprecated (it's still there, just not the
    recommended way).

Breaking changes

The breaking changes in this release are relatively minor. The biggest thing to
look out for is that request and response objects no longer implement fluent
interfaces.

  • Removed the fluent interfaces (i.e., return $this) from requests,
    responses, GuzzleHttp\Collection, GuzzleHttp\Url,
    GuzzleHttp\Query, GuzzleHttp\Post\PostBody, and
    GuzzleHttp\Cookie\SetCookie. This blog post provides a good outline of
    why I did this: http://ocramius.github.io/blog/fluent-interfaces-are-evil/.
    This also makes the Guzzle message interfaces compatible with the current
    PSR-7 message proposal.
  • Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except
    for the HTTP request functions from function.php, these functions are now
    implemented in GuzzleHttp\Utils using camelCase. GuzzleHttp\json_decode
    moved to GuzzleHttp\Utils::jsonDecode. GuzzleHttp\get_path moved to
    GuzzleHttp\Utils::getPath. GuzzleHttp\set_path moved to
    GuzzleHttp\Utils::setPath. GuzzleHttp\batch should now be
    GuzzleHttp\Pool::batch, which returns an SplObjectStorage. Using functions.php
    caused problems for many users: they aren't PSR-4 compliant, require an
    explicit include, and needed an if-guard to ensure that the functions are not
    declared multiple times.
  • Rewrote adapter layer.
    • Removing all classes from GuzzleHttp\Adapter, these are now
      implemented as callables that are stored in GuzzleHttp\Ring\Client.
    • Removed the concept of "parallel adapters". Sending requests serially or
      concurrently is now handled using a single adapter.
    • Moved GuzzleHttp\Adapter\Transaction to GuzzleHttp\Transaction. The
      Transaction object now exposes the request, response, and client as public
      properties. The getters and setters have been removed.
  • Removed the "headers" event. This event was only useful for changing the
    body a response once the headers of the response were known. You can implement
    a similar behavior in a number of ways. One example might be to use a
    FnStream that has access to the transaction being sent. For example, when the
    first byte is written, you could check if the response headers match your
    expectations, and if so, change the actual stream body that is being
    written to.
  • Removed the asArray parameter from
    GuzzleHttp\Message\MessageInterface::getHeader. If you want to get a header
    value as an array, then use the newly added getHeaderAsArray() method of
    MessageInterface. This change makes the Guzzle interfaces compatible with
    the PSR-7 interfaces.
  • GuzzleHttp\Message\MessageFactory no longer allows subclasses to add
    custom request options using double-dispatch (this was an implementation
    detail). Instead, you should now provide an associative array to the
    constructor which is a mapping of the request option name mapping to a
    function that applies the option value to a request.
  • Removed the concept of "throwImmediately" from exceptions and error events.
    This control mechanism was used to stop a transfer of concurrent requests
    from completing. This can now be handled by throwing the exception or by
    cancelling a pool of requests or each outstanding future request individually.
  • Updated to "GuzzleHttp\Streams" 3.0.
    • GuzzleHttp\Stream\StreamInterface::getContents() no longer accepts a
      maxLen parameter. This update makes the Guzzle streams project
      compatible with the current PSR-7 proposal.
    • GuzzleHttp\Stream\Stream::__construct,
      GuzzleHttp\Stream\Stream::factory, and
      GuzzleHttp\Stream\Utils::create no longer accept a size in the second
      argument. They now accept an associative array of options, including the
      "size" key and "metadata" key which can be used to provide custom metadata.