Expressive 2.0.0
Added
-
#450 adds support for PSR-11; Expressive is now a PSR-11 consumer.
-
#428 updates the zend-stratigility dependency to require
^2.0; this allows usage of both the new middleare-based error handling system introduced in zend-stratigility 1.3, as well as usage of http-interop/http-middleware implementations with Expressive. The following middleware is now supported:- Implementations of
Interop\Http\ServerMiddleware\MiddlewareInterface. - Callable middleware that implements the same signature as
Interop\Http\ServerMiddleware\MiddlewareInterface. - Callable middleware using the legacy double-pass signature (
function ($request, $response, callable $next)); these are now decorated inZend\Stratigility\Middleware\CallableMiddlewareWrapperinstances. - Service names resolving to any of the above.
- Arrays of any of the above; these will be cast to
Zend\Stratigility\MiddlewarePipeinstances, piping each middleware.
- Implementations of
-
#396 adds
Zend\Expressive\Middleware\NotFoundHandler, which provides a way to return a templated 404 response to users. This middleware should be used as innermost middleware. You may use the newZend\Expressive\Container\NotFoundHandlerFactoryto generate the instance via your DI container. -
#396 adds
Zend\Expressive\Container\ErrorHandlerFactory, for generating aZend\Stratigility\Middleware\ErrorHandlerto use with your application. If aZend\Expressive\Middleware\ErrorResponseGeneratorservice is present in the container, it will be used to seed theErrorHandlerwith a response generator. If you use this facility, you should enable thezend-expressive.raise_throwablesconfiguration flag. -
#396 adds
Zend\Expressive\Middleware\ErrorResponseGeneratorandZend\Expressive\Middleware\WhoopsErrorResponseGenerator, which may be used withZend\Stratigility\Middleware\ErrorHandlerto generate error responses. The first will generate templated error responses if a template renderer is composed, and the latter will generate Whoops output. You may use the newZend\Expressive\Container\ErrorResponseGeneratorFactoryandZend\Expressive\Container\WhoopsErrorResponseGeneratorFactory, respectively, to create these instances; if you do, assign these to the service nameZend\Expressive\Middleware\ErrorResponseGeneratorto have them automatically registered with theErrorHandler. -
#396 adds
Zend\Expressive\ApplicationConfigInjectionTrait, which exposes two methods,injectRoutesFromConfig()andinjectPipelineFromConfig(); this trait is now composed into theApplicationclass. These methods allow you to configure anApplicationinstance from configuration if desired, and are now used by theApplicationFactoryto configure theApplicationinstance. -
#396 adds a vendor binary,
vendor/bin/expressive-tooling, which will install (or uninstall) the zend-expressive-tooling; this package provides migration tools for updating your application to use programmatic pipelines and the new error handling strategy, as well as tools for identifying usage of the legacy Stratigility request and response decorators and error middleware. -
#413 adds the middleware
Zend\Expressive\Middleware\ImplicitHeadMiddleware; this middleware can be used to provide implicit support forHEADrequests when the matched route does not explicitly support the method. -
#413 adds the middleware
Zend\Expressive\Middleware\ImplicitOptionsMiddleware; this middleware can be used to provide implicit support forOPTIONSrequests when the matched route does not explicitly support the method; the returned 200 response will also include anAllowheader listing allowed HTTP methods for the URI. -
#426 adds the method
Application::getRoutes(), which will return the list ofZend\Expressive\Router\Routeinstances currently registered with the application. -
#428 adds the class
Zend\Expressive\Delegate\NotFoundDelegate, anInterop\Http\ServerMiddleware\DelegateInterfaceimplementation. The class will return a 404 response; if aTemplateRendererInterfaceis available and injected into the delegate, it will provide templated contents for the 404 response as well. We also provideZend\Expressive\Container\NotFoundDelegateFactoryfor providing an instance. -
#428 adds the method
Zend\Expressive\Application::getDefaultDelegate(). This method will return the defaultInterop\Http\ServerMiddleware\DelegateInterfaceinjected during instantiation, or, if none was injected, lazy load an instance ofZend\Expressive\Delegate\NotFoundDelegate. -
#428 adds the constants
DISPATCH_MIDDLEWAREandROUTING_MIDDLEWAREtoZend\Expressive\Application; they have identical values to the constants previously defined inZend\Expressive\Container\ApplicationFactory. -
#428 adds
Zend\Expressive\Middleware\LazyLoadingMiddleware; this essentially extracts the logic previously used withinZend\Expressive\Applicationto provide container-based middleware to allow lazy-loading only when dispatched.
Changes
-
#440 changes the
Zend\Expressive\Application::__call($method, array $args)signature; in previous versions,$argsdid not have a typehint. If you are extending the class and overriding this method, you will need to update your signature accordingly. -
#428 updates
Zend\Expressive\Container\ApplicationFactoryto ignore thezend-expressive.raise_throwablesconfiguration setting; Stratigility 2.X no longer catches exceptions in its middleware dispatcher, making the setting irrelevant. -
#422 updates the zend-expressive-router minimum supported version to 2.0.0.
-
#428 modifies the
Zend\Expressive\Container\ApplicationFactoryconstantsDISPATCH_MIDDLEWAREandROUTING_MIDDLEWAREto define themselves based on the constants of the same name now defined inZend\Expressive\Application. -
#428 modifies the constructor of
Zend\Expressive\Application; the third argument was previously a nullable callable$finalHandler; it is now a nullableInterop\Http\ServerMiddleware\DelegateInterfacewith the name$defaultDelegate. -
#450 modifies the signatures in several classes to typehint against PSR-11 instead of container-interop; these include:
Zend\Expressive\AppFactory::create()Zend\Expressive\Application::__construct()Zend\Expressive\Container\ApplicationFactory::__invoke()Zend\Expressive\Container\ErrorHandlerFactory::__invoke()Zend\Expressive\Container\ErrorResponseGeneratorFactory::__invoke()Zend\Expressive\Container\NotFoundDelegateFactory::__invoke()Zend\Expressive\Container\NotFoundHandlerFactory::__invoke()Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory::__invoke()Zend\Expressive\Container\WhoopsFactory::__invoke()Zend\Expressive\Container\WhoopsPageHandlerFactory::__invoke()
-
#450 changes the interface inheritance of
Zend\Expressive\Container\Exception\InvalidServiceExceptionto extendPsr\Container\ContainerExceptionInterfaceinstead ofInterop\Container\Exception\ContainerException.
Deprecated
- Nothing.
Removed
-
#428 removes the following routing/dispatch methods from
Zend\Expressive\Application:routeMiddleware(); this is now encapsulated inZend\Expressive\Middleware\RouteMiddleware.dispatchMiddleware(); this is now encapsulated inZend\Expressive\Middleware\DispatchMiddleware.
-
#428 removes the various "final handler" implementations and related factories. Users should now use the "default delegates" as detailed in sections previous. Classes and methods removed include:
Zend\Expressive\Application::getFinalHandler()Zend\Expressive\TemplatedErrorHandlerZend\Expressive\WhoopsErrorHandlerZend\Expressive\Container\TemplatedErrorHandlerFactoryZend\Expressive\Container\WhoopsErrorHandlerFactory
-
#428 removes the
Zend\Expressive\ErrorMiddlewarePipeclass, as zend-stratigility 2.X no longer definesZend\Stratigility\ErrorMiddlewareInterfaceor has a concept of variant-signature error middleware. Use standard middleware to provide error handling now. -
#428 removes the exception types
Zend\Expressive\Container\Exception\InvalidArgumentException(useZend\Expressive\Exception\InvalidArgumentExceptioninstead) andZend\Expressive\Container\Exception\NotFoundException(which was never used internally).
Fixed
- Nothing.