Releases: zendframework/zend-expressive
zend-expressive 3.2.1
Added
- Nothing.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #646 fixes behavior in the
MiddlewareContainerwhen retrieving
services that implement bothRequestHandlerInterfaceand
MiddlewareInterface. Previously, it incorrectly cast these values to
RequestHandlerMiddleware, which could cause middleware pipelines to fail if
they attempted to delegate back to the application middleware pipeline. These
values are now correctly returned verbatim.
zend-expressive 3.2.0
zend-expressive 3.0.3
Added
- #615 adds a cookbook entry for accessing common data in templates.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #627 fixes an issue in the Whoops response generator; previously, if an error or
exception occurred in anErrorHandlerlistener or prior to handling the pipeline,
Whoops would fail to intercept, resulting in an empty response with status 200. With
the patch, it properly intercepts and displays the errors.
zend-expressive 3.0.2
Added
- Nothing.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #612 updates the
ApplicationConfigInjectionDelegatordelegator factory logic to cast the$configvalue to an array before passing it to itsinjectPipelineFromConfig()andinjectRoutesFromConfig()methods, ensuring it will work correctly with containers that store theconfigservice as anArrayObjectinstead of anarray.
zend-expressive 3.0.1
Added
- Nothing.
Changed
- #596 updates the
ApplicationConfigInjectionDelegator::injectRoutesFromConfig()method to use the key name associated with a route specification if nonamemember is provided when creating aRouteinstance. This can help enforce name uniqueness when defining routes via configuration.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- Nothing.
zend-expressive 2.2.1
Added
- Nothing.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #592 fixes a v3 to v2 backwards port issue where the
Router\Middleware\DispatchMiddlewareis registered as an invokable and it should be registered with theRouter\Middleware\DispatchMiddlewareFactory. This caused a "DispatchMiddleware already exists and cannot be overridden" exception.
zend-expressive 3.0.0
Added
-
#543 adds support for the final PSR-15 interfaces, and explicitly depends on psr/http-server-middleware.
-
#538 adds scalar and return type hints to methods wherever possible.
-
#562 adds the class
Zend\Expressive\Response\ServerRequestErrorResponseGenerator, and maps it to theZend\Expressive\Container\ServerRequestErrorResponseGeneratorFactory. The class generates an error response when an exeption occurs producing a server request instance, and can be optionally templated. -
#543 adds a new class,
Zend\Expressive\MiddlewareContainer. The class decorates a PSR-11ContainerInterface, and adds the following behavior:- If a class is not in the container, but exists,
has()will returntrue. - If a class is not in the container, but exists,
get()will attempt to instantiate it, caching the instance locally if it is valid. - Any instance pulled from the container or directly instantiated is tested. If it is a PSR-15
RequestHandlerInterface, it will decorate it in a zend-stratigilityRequestHandlerMiddlewareinstance. If the instance is not a PSR-15MiddlewareInterface, the container will raise aZend\Expressive\Exception\InvalidMiddlewareException.
- If a class is not in the container, but exists,
-
#543 adds a new class,
Zend\Expressive\MiddlewareFactory. The class composes aMiddlewareContainer, and exposes the following methods:callable(callable $middleware) : CallableMiddlewareDecoratorhandler(RequestHandlerInterface $handler) : RequestHandlerMiddlewarelazy(string $service) : LazyLoadingMiddlewareprepare($middleware) : MiddlewareInterface: accepts a string service name, callable,RequestHandlerInterface,MiddlewareInterface, or array of such values, and returns aMiddlewareInterface, raising an exception if it cannot determine what to do.pipeline(...$middleware) : MiddlewarePipe: passes each argument toprepare(), and the result toMiddlewarePipe::pipe(), returning the pipeline when complete.
-
#543 adds the following factory classes, each within the
Zend\Expressive\Containernamespace:ApplicationPipelineFactory: creates and returns aZend\Stratigility\MiddlewarePipeto use as the application middleware pipeline.DispatchMiddlewareFactory: creates and returns aZend\Expressive\Router\DispatchMiddlewareinstance.EmitterFactory: creates and returns aZend\HttpHandlerRunner\Emitter\EmitterStackinstance composing anSapiEmitterfrom that same namespace as the only emitter on the stack. This is used as a dependency for theZend\HttpHandlerRunner\RequestHandlerRunnerservice.MiddlewareContainerFactory: creates and returns aZend\Expressive\MiddlewareContainerinstance decorating the PSR-11 container passed to the factory.MiddlewareFactoryFactory: creates and returns aZend\Expressive\MiddlewareFactoryinstance decorating aMiddlewareContainerinstance as pulled from the container.RequestHandlerRunnerFactory: creates and returns aZend\HttpHandlerRunner\RequestHandlerRunnerinstance, using the servicesZend\Expressive\Application,Zend\HttpHandlerRunner\Emitter\EmitterInterface,Zend\Expressive\ServerRequestFactory, andZend\Expressive\ServerRequestErrorResponseGenerator.ServerRequestFactoryFactory: creates and returns acallablefactory for generating a PSR-7ServerRequestInterfaceinstance; this returned factory is a dependency for theZend\HttpHandlerRunner\RequestHandlerRunnerservice.ServerRequestErrorResponseGeneratorFactory: creates and returns acallablethat accepts a PHPThrowablein order to generate a PSR-7ResponseInterfaceinstance; this returned factory is a dependency for theZend\HttpHandlerRunner\RequestHandlerRunnerservice, which uses it to generate a response in the scenario that theServerRequestFactoryis unable to create a request instance.
-
#551 and #554 add the following constants under the
Zend\Expressivenamespace:DEFAULT_DELEGATEcan be used to refer to the formerDefaultDelegateFQCN service, and maps to theZend\Expressive\Handler\NotFoundHandlerservice.IMPLICIT_HEAD_MIDDLEWAREcan be used to refer to the formerZend\Expressive\Middleware\ImplicitHeadMiddlewareservice, and maps to theZend\Expressive\Router\Middleware\ImplicitHeadMiddlewareservice.IMPLICIT_OPTIONS_MIDDLEWAREcan be used to refer to the formerZend\Expressive\Middleware\ImplicitOptionsMiddlewareservice, and maps to theZend\Expressive\Router\Middleware\ImplicitOptionsMiddlewareservice.NOT_FOUND_MIDDLEWAREcan be used to refer to the formerZend\Expressive\Middleware\NotFoundMiddlewareservice, and maps to theZend\Expressive\Handler\NotFoundHandlerservice.
Changed
-
#579 updates the version constraint for zend-expressive-router to use 3.0.0rc4 or later.
-
#579 updates the version constraint for zend-stratigility to use 3.0.0rc1 or later.
-
#543 adds a dependency on zendframework/zend-httphandlerrunner 1.0.0
-
#542 modifies the
composer.jsonto no longer suggest the pimple/pimple package, but rather the zendframework/zend-pimple-config package. -
#542 modifies the
composer.jsonto no longer suggest the aura/di package, but rather the zendframework/zend-auradi-config package. -
#543 updates the
Zend\Expressive\ConfigProviderto reflect new, removed, and updated services and their factories. -
#554 updates the
ConfigProviderto add entries for the following constants as follows:IMPLICIT_HEAD_MIDDLEWAREaliases to theZend\Expressive\Router\Middleware\ImplicitHeadMiddlewareservice.IMPLICIT_OPTIONS_MIDDLEWAREaliases to theZend\Expressive\Router\Middleware\ImplicitOptionsMiddlewareservice.
-
#543 updates
Zend\Expressive\Handler\NotFoundHandlerto implement the PSR-15RequestHandlerInterface. AsZend\Expressive\Middleware\NotFoundHandleris removed,Zend\Expressive\Container\NotFoundHandlerFactoryhas been re-purposedto create an instance ofZend\Expressive\Handler\NotFoundHandler. -
#561 modifies the
Zend\Expressive\Handler\NotFoundHandlerto compose a response factory instead of a response prototype. -
#543 refactors
Zend\Expressive\Applicationcompletely.The class no longer extends
Zend\Stratigility\MiddlewarePipe, and instead implements the PSR-15MiddlewareInterfaceandRequestHandlerInterface.It now requires the following dependencies via constructor injection, in the following order:
Zend\Expressive\MiddlewareFactoryZend\Stratigility\MiddlewarePipe; this is the pipeline representing the application.Zend\Expressive\Router\RouteCollectorZend\HttpHandlerRunner\RequestHandlerRunner
It removes all "getter" methods (as detailed in the "Removed" section of this release), but retains the following methods, with the changes described below. Please note: in most cases, these methods accept the same arguments as in the version 2 series, with the exception of callable double-pass middleware (these may be decorated manually using
Zend\Stratigility\doublePassMiddleware()), and http-interop middleware (no longer supported; rewrite as PSR-15 middleware).-
pipe($middlewareOrPath, $middleware = null) : voidpasses its arguments to the composedMiddlewareFactory'sprepare()method; if two arguments are provided, the second is passed to the factory, and the two together are passed toZend\Stratigility\path()in order to decorate them to work as middleware. The prepared middleware is then piped to the composedMiddlewarePipeinstance.As a result of switching to use the
MiddlewareFactoryto prepare middleware, you may now pipeRequestHandlerInterfaceinstances as well. -
route(string $path, $middleware, array $methods = null, string $name) : Routepasses its$middlewareargument to theMiddlewareFactory::prepare()method, and then all arguments to the composedRouteCollectorinstance'sroute()method.As a result of switching to use the
MiddlewareFactoryto prepare middleware, you may now route toRequestHandlerInterfaceinstances as well. -
Each of
get,post,patch,put,delete, andanynow proxy toroute()after marshaling the correct$methods. -
getRoutes() : Route[]proxies to the composedRouteCollectorinstance. -
handle(ServerRequestInterface $request) : ResponseInterfaceproxies to the composedMiddlewarePipeinstance'shandle()method. -
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterfaceproxies to the composedMiddlewarePipeinstance'sprocess()method. -
run() : voidproxies to the composedRequestHandlerRunnerinstance. Please note that the method no longer accepts any arguments.
-
[#543](https:/...
zend-expressive 3.0.0rc5
This release contains a breaking change.
This release updates to zend-expressive-router 3.0.0rc5, which renames Zend\Expressive\Router\Middleware\PathBasedRoutingMiddleware to Zend\Expressive\Router\RouteCollector, and drops its extension of RouteMiddleware. This was done to prevent confusion between the two route middleware implementations in the final release, and because the primariy duty of the (newly renamed) RouteCollector is to produce and inject Route instances into the composed router.
This release of zend-expressive required one change to comply: Zend\Expressive\Application now composes a RouteCollector instead of a PathBasedRoutingMiddleware instance.
Below is a cumulative list of changes for the 3.0.0 release, including all changes from previous alpha and RC releases. References to PathBasedRoutingMiddleware have been updated to reference RouteCollector or RouteMiddleware based on context:
Added
-
#543 adds support for the final PSR-15 interfaces, and explicitly depends on psr/http-server-middleware.
-
#538 adds scalar and return type hints to methods wherever possible.
-
#562 adds the class
Zend\Expressive\Response\ServerRequestErrorResponseGenerator, and maps it to theZend\Expressive\Container\ServerRequestErrorResponseGeneratorFactory. The class generates an error response when an exeption occurs producing a server request instance, and can be optionally templated. -
#543 adds a new class,
Zend\Expressive\MiddlewareContainer. The class decorates a PSR-11ContainerInterface, and adds the following behavior:- If a class is not in the container, but exists,
has()will returntrue. - If a class is not in the container, but exists,
get()will attempt to instantiate it, caching the instance locally if it is valid. - Any instance pulled from the container or directly instantiated is tested. If it is a PSR-15
RequestHandlerInterface, it will decorate it in a zend-stratigilityRequestHandlerMiddlewareinstance. If the instance is not a PSR-15MiddlewareInterface, the container will raise aZend\Expressive\Exception\InvalidMiddlewareException.
- If a class is not in the container, but exists,
-
#543 adds a new class,
Zend\Expressive\MiddlewareFactory. The class composes aMiddlewareContainer, and exposes the following methods:callable(callable $middleware) : CallableMiddlewareDecoratorhandler(RequestHandlerInterface $handler) : RequestHandlerMiddlewarelazy(string $service) : LazyLoadingMiddlewareprepare($middleware) : MiddlewareInterface: accepts a string service name, callable,RequestHandlerInterface,MiddlewareInterface, or array of such values, and returns aMiddlewareInterface, raising an exception if it cannot determine what to do.pipeline(...$middleware) : MiddlewarePipe: passes each argument toprepare(), and the result toMiddlewarePipe::pipe(), returning the pipeline when complete.
-
#543 adds the following factory classes, each within the
Zend\Expressive\Containernamespace:ApplicationPipelineFactory: creates and returns aZend\Stratigility\MiddlewarePipeto use as the application middleware pipeline.DispatchMiddlewareFactory: creates and returns aZend\Expressive\Router\DispatchMiddlewareinstance.EmitterFactory: creates and returns aZend\HttpHandlerRunner\Emitter\EmitterStackinstance composing anSapiEmitterfrom that same namespace as the only emitter on the stack. This is used as a dependency for theZend\HttpHandlerRunner\RequestHandlerRunnerservice.MiddlewareContainerFactory: creates and returns aZend\Expressive\MiddlewareContainerinstance decorating the PSR-11 container passed to the factory.MiddlewareFactoryFactory: creates and returns aZend\Expressive\MiddlewareFactoryinstance decorating aMiddlewareContainerinstance as pulled from the container.RequestHandlerRunnerFactory: creates and returns aZend\HttpHandlerRunner\RequestHandlerRunnerinstance, using the servicesZend\Expressive\Application,Zend\HttpHandlerRunner\Emitter\EmitterInterface,Zend\Expressive\ServerRequestFactory, andZend\Expressive\ServerRequestErrorResponseGenerator.ServerRequestFactoryFactory: creates and returns acallablefactory for generating a PSR-7ServerRequestInterfaceinstance; this returned factory is a dependency for theZend\HttpHandlerRunner\RequestHandlerRunnerservice.ServerRequestErrorResponseGeneratorFactory: creates and returns acallablethat accepts a PHPThrowablein order to generate a PSR-7ResponseInterfaceinstance; this returned factory is a dependency for theZend\HttpHandlerRunner\RequestHandlerRunnerservice, which uses it to generate a response in the scenario that theServerRequestFactoryis unable to create a request instance.
-
#551 and #554 add the following constants under the
Zend\Expressivenamespace:DEFAULT_DELEGATEcan be used to refer to the formerDefaultDelegateFQCN service, and maps to theZend\Expressive\Handler\NotFoundHandlerservice.IMPLICIT_HEAD_MIDDLEWAREcan be used to refer to the formerZend\Expressive\Middleware\ImplicitHeadMiddlewareservice, and maps to theZend\Expressive\Router\Middleware\ImplicitHeadMiddlewareservice.IMPLICIT_OPTIONS_MIDDLEWAREcan be used to refer to the formerZend\Expressive\Middleware\ImplicitOptionsMiddlewareservice, and maps to theZend\Expressive\Router\Middleware\ImplicitOptionsMiddlewareservice.NOT_FOUND_MIDDLEWAREcan be used to refer to the formerZend\Expressive\Middleware\NotFoundMiddlewareservice, and maps to theZend\Expressive\Handler\NotFoundHandlerservice.
Changed
-
#579 updates the version constraint for zend-expressive-router to use 3.0.0rc4 or later.
-
#579 updates the version constraint for zend-stratigility to use 3.0.0rc1 or later.
-
#543 adds a dependency on zendframework/zend-httphandlerrunner 1.0.0
-
#542 modifies the
composer.jsonto no longer suggest the pimple/pimple package, but rather the zendframework/zend-pimple-config package. -
#542 modifies the
composer.jsonto no longer suggest the aura/di package, but rather the zendframework/zend-auradi-config package. -
#543 updates the
Zend\Expressive\ConfigProviderto reflect new, removed, and updated services and their factories. -
#554 updates the
ConfigProviderto add entries for the following constants as follows:IMPLICIT_HEAD_MIDDLEWAREaliases to theZend\Expressive\Router\Middleware\ImplicitHeadMiddlewareservice.IMPLICIT_OPTIONS_MIDDLEWAREaliases to theZend\Expressive\Router\Middleware\ImplicitOptionsMiddlewareservice.
-
#543 updates
Zend\Expressive\Handler\NotFoundHandlerto implement the PSR-15RequestHandlerInterface. AsZend\Expressive\Middleware\NotFoundHandleris removed,Zend\Expressive\Container\NotFoundHandlerFactoryhas been re-purposedto create an instance ofZend\Expressive\Handler\NotFoundHandler. -
#561 modifies the
Zend\Expressive\Handler\NotFoundHandlerto compose a response factory instead of a response prototype. -
#543 refactors
Zend\Expressive\Applicationcompletely.The class no longer extends
Zend\Stratigility\MiddlewarePipe, and instead implements the PSR-15MiddlewareInterfaceandRequestHandlerInterface.It now requires the following dependencies via constructor injection, in the following order:
Zend\Expressive\MiddlewareFactoryZend\Stratigility\MiddlewarePipe; this is the pipeline representing the application.Zend\Expressive\Router\RouteCollectorZend\HttpHandlerRunner\RequestHandlerRunner
It removes all "getter" methods (as detailed in the "Removed" section of this release), but retains the following methods, with the changes described below. Please note: in most cases, these methods accept the same arguments as in the version 2 series, with the exception of callable double-pass middleware (these may be decorated manually using
Zend\Stratigility\doublePassMiddleware()), and http-interop middleware (no longer supported; rewrite as PSR-15 middleware).-
pipe($middlewareOrPath, $middleware = null) : voidpasses its arguments to the composedMiddlewareFactory'sprepare()method; if two arguments are provided, the second is passed to the factory, and the two together are passed toZend\Stratigility\path()in order to decorate them to work as middleware. The prepared middleware is then piped to the composedMiddlewarePipeinstance.As a result of switching to use the
MiddlewareFactoryto prepare middleware, you may now pipeRequestHandlerInterfaceinstances as well. -
route(string $path, $middleware, array $methods = null, string $name) : Routepasses its$middlewareargument to the `Middleware...
zend-expressive 3.0.0rc4
Added
- Nothing.
Changed
- Forward ports a change made in #581 to how the
ApplicationConfigInjectionDelegator::injectPipelineFromConfig()method works. Previously, it would auto-inject routing and dispatch middleware if routes were configured, but nomiddleware_pipelinewas present. Considering that this method will always be called manually, this functionality was removed; the method now becomes a no-op if nomiddleware_pipelineis present.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- Nothing.
zend-expressive 2.2.0
Added
-
#581 adds the class
Zend\Expressive\ConfigProvider, and exposes it to the zend-component-installer Composer plugin. We recommend updating yourconfig/config.phpto reference it, as well as theZend\Expressive\Router\ConfigProvidershipped with zend-expressive-router versions 2.4 and up. -
#581 adds the class
Zend\Expressive\Container\ApplicationConfigInjectionDelegator. The class can act as a delegator factory, and, when enabled, will inject routes and pipeline middleware defined in configuration.Additionally, the class exposes two static methods:
injectPipelineFromConfig(Application $app, array $config)injectRoutesFromConfig(Application $app, array $config)
These may be called to modify an
Applicationinstance based on an array of configuration. See thd documentation for more details. -
#581 adds the class
Zend\Expressive\Handler\NotFoundHandler; the class takes over the functionality previously provided inZend\Expressive\Delegate\NotFoundDelegate.
Changed
-
#581 updates the minimum supported zend-stratigility version to 2.2.0.
-
#581 updates the minimum supported zend-expressive-router version to 2.4.0.
Deprecated
-
#581 deprecates the following classes and traits:
-
Zend\Expressive\AppFactory: if you are using this, you will need to switch to direct usage ofZend\Expressive\Applicationor aZend\Stratigility\MiddlewarePipeinstance. -
Zend\Expressive\ApplicationConfigInjectionTrait: if you are using it, it is marked internal, and deprecated; it will be removed in version 3. -
Zend\Expressive\Container\NotFoundDelegateFactory: theNotFoundDelegatewill be renamed toZend\Expressive\Handler\NotFoundHandlerin version 3, making this factory obsolete. -
Zend\Expressive\Delegate\NotFoundDelegate: this class becomesZend\Expressive\Handler\NotFoundHandlerin v3, and the new class is added in version 2.2 as well. -
Zend\Expressive\Emitter\EmitterStack: the emitter concept is extracted from zend-diactoros to a new component, zend-httphandlerrunner. This latter component is used in version 3, and defines theEmitterStackclass. Unless you are extending it or interacting with it directly, this change should not affect you; theZend\Diactoros\Response\EmitterInterfaceservice will be directed to the new class in that version. -
Zend\Expressive\IsCallableInteropMiddlewareTrait: if you are using it, it is marked internal, and deprecated; it will be removed in version 3. -
Zend\Expressive\MarshalMiddlewareTrait: if you are using it, it is marked internal, and deprecated; it will be removed in version 3. -
Zend\Expressive\Middleware\DispatchMiddleware: this functionality has been moved to zend-expressive-router, under theZend\Expressive\Router\Middlewarenamespace. -
Zend\Expressive\Middleware\ImplicitHeadMiddleware: this functionality has been moved to zend-expressive-router, under theZend\Expressive\Router\Middlewarenamespace. -
Zend\Expressive\Middleware\ImplicitOptionsMiddleware: this functionality has been moved to zend-expressive-router, under theZend\Expressive\Router\Middlewarenamespace. -
Zend\Expressive\Middleware\NotFoundHandler: this will be removed in version 3, where you can instead pipeZend\Expressive\Handler\NotFoundHandlerdirectly instead. -
Zend\Expressive\Middleware\RouteMiddleware: this functionality has been moved to zend-expressive-router, under theZend\Expressive\Router\Middlewarenamespace.
-
-
#581 deprecates the following methods from
Zend\Expressive\Application:pipeRoutingMiddleware()pipeDispatchMiddleware()getContainer(): this method is removed in version 3; container access will only be via the bootstrap.getDefaultDelegate(): the concept of a default delegate is removed in version 3.getEmitter(): emitters move to a different collaborator in version 3.injectPipelineFromConfig()anddinjectRoutesFromConfig()are methods defined by theApplicationConfigInjectionTrait, which will be removed in version 3. Use theApplicationConfigInjectionDelegatorinstead.
Removed
- Nothing.
Fixed
- Nothing.