Laminas Stratigility v1.3.0 Release Notes

Release Date: 2016-11-10 // almost 7 years ago
  • โž• Added

    • zendframework/zend-stratigility#66 adds a new class, Laminas\Stratigility\Middleware\NotFoundHandler. This class may be piped into an application at an innermost layer; when invoked, it will return a 404 plain text response.

    • zendframework/zend-stratigility#66 adds a new class, Laminas\Stratigility\Middleware\ErrorHandler. This class may be piped into an application, typically at the outermost or one of the outermost layers. When invoked, it does the following:

      • Creates a PHP error handler that will re-throw PHP errors as ErrorExceptions.
      • Dispatches to the next layer.
      • If the next layer does not return a response, it raises a new MissingResponseException.
      • Catches all exceptions from calling the next layer, and passes them to an error response generator to return an error response.

    A default error response generator is provided, which will return a 5XX series response in plain text. You may provide a callable generator to the constructor in order to customize the response generated; please refer to the documentation for details.

    • zendframework/zend-stratigility#66 adds a new class, Laminas\Stratigility\NoopFinalHandler. This class may be provided as the $out argument to a MiddlewarePipe, or as the final handler to Laminas\Diactoros\Server::listen() (in which case it will be passed to the middleware you invoke as the application). This handler returns the response provided to it verbatim.

    • zendframework/zend-stratigility#70 adds a new class, Laminas\Stratigility\Middleware\OriginalMessages. Compose this middleware in an outermost layer, and it will inject the following attributes in the request passed to nested layers:

      • originalRequest, representing the request provided to it.
      • originalResponse, representing the response provided to it.
      • originalUri, representing URI instance composed in the request provided to it.
    • ๐Ÿ‘ zendframework/zend-stratigility#75 adds support for http-interop middleware 0.2.0. For full details, see the migration guide. As a summary of features:

      • You may now pipe http-interop middleware to MiddlewarePipe instances.
      • You may now pipe callable middleware that defines the same signature as http-interop middleware to MiddlewarePipe instances; these will be decorated in a Laminas\Stratigility\Middleware\CallableInteropMiddlewareWrapper instance.
      • MiddlewarePipe now implements the http-interop ServerMiddlewareInterface, allowing it to be used in http-interop middleware dispatchers.
    • zendframework/zend-stratigility#75 adds the class Laminas\Stratigility\Middleware\CallableMiddlewareWrapper. It accepts callable double-pass middleware and a response prototype, and implements the http-interop ServerMiddlewareInterface, allowing you to adapt existing callable middleware to work with http-interop middleware dispatchers.

    • zendframework/zend-stratigility#75 adds the class Laminas\Stratigility\Middleware\CallableInteropMiddlewareWrapper. It accepts callable middleware that follows the http-interop ServerMiddlewareInterface, and implements that interface itself, to allow composing such middleware in http-interop middleware dispatchers.

    • zendframework/zend-stratigility#75 adds the class Laminas\Stratigility\Delegate\CallableDelegateDecorator, which can be used to add http-interop middleware support to your existing callable middleware.

    • zendframework/zend-stratigility#75 adds a new method to MiddlewarePipe, setResponseProtoype(). When this method is invoked with a PSR-7 response, the following occurs:

      • That response is injected in Next and Dispatch instances, to allow dispatching legacy callable middleware as if it were http-interop middleware.
      • Any callable middleware implementing the legacy signature will now be decorated using the above CallableMiddlewareWrapper in order to adapt it as http-interop middleware.
    • zendframework/zend-stratigility#78 adds a new method to each of Laminas\Stratigility\MiddlewarePipe, Next, and Dispatch: raiseThrowables(). When called, Dispatch will no longer wrap dispatch of middleware in a try/catch block, allowing throwables/exceptions to bubble out. This enables the ability to create error handling middleware as an outer layer or your application instead of relying on error middleware and/or the final handler. Typical usage will be to call the method on the MiddlewarePipe before dispatching it.

    ๐Ÿ”„ Changed

    • zendframework/zend-stratigility#70 makes the following changes to Laminas\Stratigility\FinalHandler:

      • It now pulls the original request using the originalRequest attribute, instead of getOriginalRequest(); see the deprecation of Laminas\Stratigility\Http\Request, below, for why this works.
      • It no longer writes to the response using the Laminas\Stratigility\Http\Response-specific write() method, but rather pulls the message body and writes to that.
    • โšก๏ธ zendframework/zend-stratigility#75 updates MiddlewarePipe to inject the $response argument to __invoke() as the response prototype.

    • โšก๏ธ zendframework/zend-stratigility#75 updates Laminas\Stratigility\Next to implement the http-interop middleware DelegateInterface. It also updates Laminas\Stratigility\Dispatch to add a new method, process(), following the DelegateInterface signature, thus allowing Next to properly process http-interop middleware. These methods will use the composed response prototype, if present, to invoke callable middleware using the legacy signature.

    • โšก๏ธ zendframework/zend-stratigility#75 updates Next to allow the $done constructor argument to be an http-interop DelegateInterface, and will invoke it as such if the queue is exhausted.

    • โšก๏ธ zendframework/zend-stratigility#75 updates Route (which is used internally by MiddlewarePipe to allow either callable or http-interop middleware as route handlers.

    ๐Ÿ—„ Deprecated

    • ๐Ÿ—„ zendframework/zend-stratigility#66 deprecates the Laminas\Stratigility\FinalHandler class. We now recommend using the NoopFinalHandler, along with the ErrorHandler and NotFoundHandler middleware (or equivalents) to provide a more fine-grained, flexible, error handling solution for your applications.

    • ๐Ÿ—„ zendframework/zend-stratigility#66 deprecates the Laminas\Stratigility\Dispatch class. This class is used internally by Next, and deprecation should not affect the majority of users.

    • ๐Ÿ—„ zendframework/zend-stratigility#66 deprecates Laminas\Stratigility\ErrorMiddlewareInterface. We recommend instead using exceptions, along with the ErrorHandler, to provide error handling for your application.

    • โšก๏ธ zendframework/zend-stratigility#66 updates Laminas\Stratigility\MiddlewarePipe::__invoke() to emit a deprecation notice if no $out argument is provided, as version 2 will require it.

    • โšก๏ธ zendframework/zend-stratigility#66 updates Laminas\Stratigility\Next::__invoke() to emit a deprecation notice if a non-null $err argument is provided; middleware should raise an exception, instead of invoking middleware implementing ErrorMiddlewareInterface.

    • ๐Ÿ—„ zendframework/zend-stratigility#70 deprecates Laminas\Stratigility\Http\Request. Additionally:

      • The composed "PSR Request" is now injected with an additional attribute, originalRequest, allowing retrieval using standard PSR-7 attribute access.
      • The methods getCurrentRequest() and getOriginalRequest() now emit deprecation notices when invoked, urging users to update their code.
    • ๐Ÿ—„ zendframework/zend-stratigility#70 deprecates Laminas\Stratigility\Http\ResponseInterface.

    • ๐Ÿ—„ zendframework/zend-stratigility#70 deprecates Laminas\Stratigility\Http\Response. Additionally, the methods write(), end(), isComplete(), and getOriginalResponse() now emit deprecation notices when invoked, urging users to update their code.

    • ๐Ÿ—„ zendframework/zend-stratigility#75 deprecates the $response argument in existing callable middleware. Please only operate on the response returned by $next/$delegate, or create a response. See the documentation section on response arguments for more details.

    • ๐Ÿ—„ zendframework/zend-stratigility#75 deprecates usage of error middleware, and thus deprecates the $err argument to $next; explicitly invoking error middleware using that argument to $next will now raise a deprecation notice.

    โœ‚ Removed

    • Nothing.

    ๐Ÿ›  Fixed

    • Nothing.