Releases: zendframework/zend-expressive
zend-expressive 3.0.0alpha3
Added
- Nothing.
Changed
-
#546 merges
Zend\Expressive\Middleware\NotFoundHandler
intoZend\Expressive\Middleware\NotFoundMiddleware
, as well as mergesZend\Expressive\Container\NotFoundHandlerFactory
intoZend\Expressive\Container\NotFoundMiddlewareFactory
.NotFoundMiddleware
now does the work of the formerZend\Expressive\Delegate\NotFoundDelegate
, and, as such, accepts the following constructor arguments:- PSR-7
ResponseInterface $responsePrototype
(required) Zend\Expressive\Template\TemplateRendererInterface $renderer
(optional)string $template = self::TEMPLATE_DEFAULT
(optional; defaults to "error::404")string $layout = self::LAYOUT_DEFAULT
(optional; defaults to "layout::default")
- PSR-7
Deprecated
- Nothing.
Removed
- #546 removes the class
Zend\Expressive\Delegate\DefaultDelegate
, as there is no longer a concept of a default handler invoked by the application. Instead, developers MUST pipe middleware at the innermost layer of the pipeline guaranteed to return a response; we recommend usingZend\Expressive\Middleware\NotFoundMiddleware
for this purpose.
Fixed
- Nothing.
zend-expressive 3.0.0alpha2
Added
-
#543 adds support for the final PSR-15 interfaces, and explicitly depends on psr/http-server-middleware.
-
#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-stratigilityRequestHandlerMiddleware
instance. 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) : CallableMiddlewareDecorator
handler(RequestHandlerInterface $handler) : RequestHandlerMiddleware
lazy(string $service) : LazyLoadingMiddleware
prepare($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\Container
namespace:ApplicationPipelineFactory
: creates and returns aZend\Stratigility\MiddlewarePipe
to use as the application middleware pipeline.DispatchMiddlewareFactory
: creates and returns aZend\Expressive\Router\DispatchMiddleware
instance.EmitterFactory
: creates and returns aZend\HttpHandlerRunner\Emitter\EmitterStack
instance composing anSapiEmitter
from that same namespace as the only emitter on the stack. This is used as a dependency for theZend\HttpHandlerRunner\RequestHandlerRunner
service.MiddlewareContainerFactory
: creates and returns aZend\Expressive\MiddlewareContainer
instance decorating the PSR-11 container passed to the factory.MiddlewareFactoryFactory
: creates and returns aZend\Expressive\MiddlewareFactory
instance decorating aMiddlewareContainer
instance as pulled from the container.RequestHandlerRunnerFactory
: creates and returns aZend\HttpHandlerRunner\RequestHandlerRunner
instance, using the servicesZend\Expressive\Application
,Zend\HttpHandlerRunner\Emitter\EmitterInterface
,Zend\Expressive\ServerRequestFactory
, andZend\Expressive\ServerRequestErrorResponseGenerator
.RouteMiddlewareFactory
: creates and returns aZend\Expressive\Router\PathBasedRoutingMiddleware
instance.ServerRequestFactoryFactory
: creates and returns acallable
factory for generating a PSR-7ServerRequestInterface
instance; this returned factory is a dependency for theZend\HttpHandlerRunner\RequestHandlerRunner
service.ServerRequestErrorResponseGeneratorFactory
: creates and returns acallable
that accepts a PHPThrowable
in order to generate a PSR-7ResponseInterface
instance; this returned factory is a dependency for theZend\HttpHandlerRunner\RequestHandlerRunner
service, which uses it to generate a response in the scenario that theServerRequestFactory
is unable to create a request instance.
-
#543 adds the class
Zend\Expressive\Container\ApplicationConfigInjectionDelegator
. This class may be used either as a delegator factory on theZend\Expressive\Application
instance, or you may use the two static methods it defines to inject pipeline middleware and/or routes from configuration:injectPipelineFromConfig(Application $application, array $config) : void
injectRoutesFromConfig(Application $application, array $config) : void
These methods work the same way as the associated
Application
methods from version 2, accepting the same configuration. -
#543 adds
Zend\Expressive\ConfigProvider
, which details the default service mappings.
Changed
-
#543 adds dependencies on each of:
- zend-stratigility 3.0.0alpha3
- zend-expressive-router 3.0.0alpha1
- zend-httphandlerrunner 1.0.0
and removes the dependency http-interop/http-server-middleware.
-
#543 renames
Zend\Expressive\Middleware\NotFoundHandler
toZend\Expressive\Middleware\NotFoundMiddleware
, and its accompanying factoryZend\Expressive\Container\NotFoundHandlerFactory
toZend\Expressive\Container\NotFoundMiddlewareFactory
. -
#543 renames
Zend\Expressive\Delegate\NotFoundDelegate
toZend\Expressive\Handler\NotFoundHandler
, updating it to implement the PSR-15RequestHandlerInterface
. It also renames the factoryZend\Expressive\Container\NotFoundDelegateFactory
toZend\Expressive\Container\NotFoundHandlerFactory
. -
#543 refactors
Zend\Expressive\Application
completely.The class no longer extends
Zend\Stratigility\MiddlewarePipe
, and instead implements the PSR-15MiddlewareInterface
andRequestHandlerInterface
.It now requires the following dependencies via constructor injection, in the following order:
Zend\Expressive\MiddlewareFactory
Zend\Stratigility\MiddlewarePipe
; this is the pipeline representing the application.Zend\Expressive\Router\PathBasedRoutingMiddleware
Zend\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) : void
passes 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 composedMiddlewarePipe
instance.As a result of switching to use the
MiddlewareFactory
to prepare middleware, you may now pipeRequestHandlerInterface
instances as well. -
route(string $path, $middleware, array $methods = null, string $name) : Route
passes its$middleware
argument to theMiddlewareFactory::prepare()
method, and then all arguments to the composedPathBasedRoutingMiddleware
instance'sroute()
method.As a result of switching to use the
MiddlewareFactory
to prepare middleware, you may now route toRequestHandlerInterface
instances as well. -
Each of
get
,post
,patch
,put
,delete
, andany
now proxy toroute()
after marshaling the correct$methods
. -
getRoutes() : Route[]
proxies to the composedPathBasedRoutingMiddleware
instance. -
handle(ServerRequestInterface $request) : ResponseInterface
proxies to the composedMiddlewarePipe
instance'shandle()
method. -
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
proxies to the composedMiddlewarePipe
instance'sprocess()
method. -
run() : void
proxies to the composedRequestHandlerRunner
instance. Please note that the method no longer accepts any arguments.
-
#543 modifies the
Zend\Expressive\Container\ApplicationFactory
to reflect the changes to theZend\Expressive\Application
class as detailed above. It pulls the following services to inject via the constructor:Zend\Expressive\MiddlewareFactory
Zend\Stratigility\ApplicationPipeline
, which should resolve to aMiddlewarePipe
instance; use theZend\Expressive\Container\ApplicationPipelineFactory
.Zend\Expressive\Router\PathBasedRoutingMiddleware
Zend\HttpHandlerRunner\RequestHandlerRunner
Deprecated
- Nothing.
Removed
-
#543 removes support for http-interop/http-server-middleware.
-
#543 removes the class
Zend\Expressive\Middleware\RouteMiddleware
. Use thePathBasedRoutingMiddleware
orRouteMiddleware
from zend-expressive-router instead; the factoryZend\Expressive\Container\RouteMiddlewareFactory
will return aPathBasedRoutingMiddleware
instance for you. -
#543 removes the class
Zend\Expressive\Middleware\DispatchMiddleware
. Use theDispatchMiddleware
from zend-expressive-router instead; the factoryZend\Expressive\Container\DispatchMiddlewareFactory
will return an instance for you. -
#543 removes the class
Zend\Expressive\Emitter\EmitterStack
; use the cl...
zend-expressive 3.0.0alpha1
Added
-
#529 adds support for http-interop/http-server-middleware (PSR-15 pre-cursor).
-
#538 adds scalar and return type hints to methods wherever possible.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
-
#529 removes support for PHP versions prior to PHP 7.1.
-
#529 removes support for http-interop/http-middleware (previous PSR-15 iteration).
Fixed
- Nothing.
Expressive 2.1.0
Added
- #480 updates the
ImplicitHeadMiddleware
to add a request attribute indicating the request was originally generated for aHEAD
request before delegating the request; you can now pull the attributeZend\Expressive\Middleware\ImplicitHeadMiddleware::FORWARDED_HTTP_METHOD_ATTRIBUTE
in your own middleware in order to vary behavior in these scenarios.
Changed
-
#505 modifies
Zend\Expressive\Application
to remove implementation of__call()
in favor of the following new methods:get($path, $middleware, $name = null)
post($path, $middleware, $name = null)
put($path, $middleware, $name = null)
patch($path, $middleware, $name = null)
delete($path, $middleware, $name = null)
This change is an internal implementation detail only, and will not affect existing implementations or extensions.
-
#511 modifies the
NotFoundDelegate
to accept an optional$layout
argument to its constructor; the value defaults tolayout::default
if not provided. That value will be passed for thelayout
template variable when the delegate renders a template, allowing zend-view users (and potentially other template systems) to customize the layout template used for reporting errors.You may provide the template via the configuration
zend-expressive.error_handler.layout
.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- Nothing.
Expressive 2.0.6
Added
- Nothing.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #534 provides a fix for how it detects
callable
middleware. Previously, it relied on PHP'sis_callable()
, but that function can result in false positives when provided a 2-element array where the first element is an object, as the function does not verify that the second argument is a valid method of the first. We now implement additional verifications to prevent such false positives.
Expressive 2.0.5
Added
- Nothing.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #521 adds an explicit requirement on http-interop/http-middleware
^0.4.1
to the package. This is necessary as newer builds of zend-stratigility instead depend on the metapackage webimpress/http-middleware-compatibility instead of the http-interop/http-middleware package — but middleware shipped in Expressive requires it. This addition fixes problems due to missing http-middleware interfaces.
Expressive 2.0.4
Added
- #508 adds documentation covering
Zend\Expressive\Helper\ContentLengthMiddleware
, introduced in zend-expressive-helpers 4.1.0.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #479 fixes the
WhoopsErrorResponseGenerator::$whoops
dockblock Type to support Whoops 1 and 2. - #482 fixes the
Application::$defaultDelegate
dockblock Type. - #489 fixes an edge case in the
WhoopsErrorHandler
whereby it would emit an error if$_SERVER['SCRIPT_NAME']
did not exist. It now checks for that value before attempting to use it.
Expressive 2.0.3
Added
- Nothing.
Changed
- #468 updates references to
DefaultDelegate::class
to instead use the string'Zend\Expressive\Delegate\DefaultDelegate'
; using the string makes it clear that the service name does not resolve to an actual class.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #476 fixes the
WhoopsErrorResponseGenerator
to ensure it returns a proper error status code, instead of using a200 OK
status.
Expressive 2.0.2
Added
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #467 fixes an issue when passing invokable, duck-typed, interop middleware to the application without registering it with the container. Prior to the patch, it was incorrectly being decorated by
Zend\Stratigility\Middleware\CallableMiddlewareWrapper
instead ofZend\Stratigility\Middleware\CallableInteropMiddlewareWrapper
.
Expressive 2.0.1
Added
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #464 fixes the
WhoopsErrorResponseGenerator
to provide a correctContent-Type
header to the response when a JSON request occurs.