Releases: zendframework/zend-expressive-router
zend-expressive-router 3.1.1
Added
- #80 adds support for PHP 7.3.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- Nothing.
zend-expressive-router 3.1.0
Added
- Nothing.
Changed
- #76 modifies the
RouteMiddlewareFactory
to allow specifying a string
$routererviceName
to its constructor. This change allows having discrete
factory instances for generating route middleware that use different router
instances.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- Nothing.
zend-expressive-router 3.0.3
Added
- Nothing.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #74 fixes
an issue with theImplicitHeadMiddleware
where matched route parameters
were not copied into the request and would cause exceptions that would
normally not happen for GET requests.
zend-expressive-router 3.0.2
Added
- Nothing.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #73 fixes an issue with the
ImplicitOptionsMiddleware
whereby a path match failure was incorrectly being identified as a method match failure, triggering theImplicitOptionsMiddleware
to attempt to return a response.
zend-expressive-router 3.0.1
Added
- Nothing.
Changed
- Nothing.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- #69 fixes the exception message emitted for missing dependencies when creating a
RouteCollector
instance to refer that class.
zend-expressive-router 3.0.0
Added
-
#50 adds
Zend\Expressive\Router\ConfigProvider
, and registers it with the package. The class defines and returns the initial dependencies for the package. -
#50 adds factory classes for all shipped middleware. In some cases (
ImplicitHeadMiddleware
,ImplicitOptionsMiddleware
, andMethodNotAllowedMiddleware
), these rely on additional services that you will need to configure within your application in order to work properly. See each factory for details. -
#47, #50, and #64 add the
Zend\Expressive\Router\RouteCollector
class, which composes aRouterInterface
, and provides methods for defining and creating path+method based routes. It exposes the following methods:route(string $path, MiddlewareInterface $middleware, array $methods = null, string $name = null) : Route
get(string $path, MiddlewareInterface $middleware, string $name = null) : Route
post(string $path, MiddlewareInterface $middleware, string $name = null) : Route
put(string $path, MiddlewareInterface $middleware, string $name = null) : Route
patch(string $path, MiddlewareInterface $middleware, string $name = null) : Route
delete(string $path, MiddlewareInterface $middleware, string $name = null) : Route
any(string $path, MiddlewareInterface $middleware, string $name = null) : Route
-
#48 and #50 adds
Zend\Expressive\Router\Middleware\MethodNotAllowedMiddleware
. This middleware checks if the request composes aRouteResult
, and, if so, if it is due to a method failure. If neither of those conditions is true, it delegates processing of the request to the handler. Otherwise, it uses a composed response prototype in order to create a "405 Method Not Allowed" response, with anAllow
header containing the list of allowed request methods. -
#49 and #50 add the class
Zend\Expressive\Router\Middleware\ImplicitHeadMiddleware
. This middleware will answer aHEAD
request for a given route. If no route was matched, or the route allowsHEAD
requests, it delegates to the handler. If the route does not allow aGET
request, it returns an empty response, as composed in the middleware. Otherwise, it issues aGET
request to the handler, indicating the method was forwarded for aHEAD
request, and then returns the response with an empty body. -
#49 and #50 add the class
Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware
. This middleware handlesOPTIONS
requests when a route result is present and the route does not explicitly supportOPTIONS
(and otherwise delegates to the handler). In those conditions, it returns the response composed in the middleware, with anAllow
header indicating the allowed methods. -
#53 and #58 add an abstract test case,
Zend\Expressive\Router\Test\ImplicitMethodsIntegrationTest
. Implementors ofRouterInterface
should extend this class in their own test suite to ensure that they create appropriateRouteResult
instances for each of the following cases:HEAD
request called and matches one or more known routes, but the method is not defined for any of them.OPTIONS
request called and matches one or more known routes, but the method is not defined for any of them.- Request matches one or more known routes, but the method is not allowed.
In particular, these tests ensure that implementations marshal the list of allowed HTTP methods correctly in the latter two cases.
Changed
-
#41 updates the
Route
class to provide typehints for all arguments and return values. Typehints were generally derived from the existing annotations, with the following items of particular note:- The constructor
$middleware
argument typehints on the PSR-15MiddlewareInterface
. - The
getMiddleware()
method now explicitly returns a PSR-15MiddlewareInterface
instance. getAllowedMethods()
now returns a nullablearray
.
- The constructor
-
#41 and #43 update the
RouteResult
class to add typehints for all arguments and return values, where possible. Typehints were generally derived from the existing annotations, with the following items of particular note:- The
$methods
argument tofromRouteFailure()
is now a nullable array (withnull
representing the fact that any method is allowed), without a default value. You must provide a value when creating a route failure. getAllowedMethods()
will now return['*']
when any HTTP method is allowed; this will evaluate to a validAllows
header value, and is the recommended value when any HTTP method is allowed.
- The
-
#41 updates the
RouteInterface
to add typehints for all arguments and return values. In particular, thse are now:addRoute(Route $route) : void
match(Psr\Http\Message\ServerRequestInterface $request) : RouteResult
generateUri(string $name, array $substitutions = [], array $options = []) : string
-
#47 modifies the
RouteMiddleware::$router
property to make itprotected
visibility, allowing extensions to work with it. -
#48 modifies
Zend\Expressive\Router\Route
to implement the PSR-15MiddlewareInterface
. The newprocess()
method proxies to the composed middleware. -
#48 modifies
Zend\Expressive\Router\RouteResult
to implement the PSR-15MiddlewareInterface
. The newprocess()
method proxies to the composedRoute
instance in the case of a success, and otherwise delegates to the passed handler instance. -
#48 modifies
Zend\Expressive\Router\DispatchMiddleware
to process theRouteResult
directly, instead of pulling middleware from it. -
#50 renames
Zend\Expressive\Router\RouteMiddleware
toZend\Expressive\Router\Middleware\RouteMiddleware
. -
#50 renames
Zend\Expressive\Router\DispatchMiddleware
toZend\Expressive\Router\Middleware\DispatchMiddleware
. -
#58 changes the constructor of
ImplicitHeadMiddleware
to accept aRouterInterface
instead of a response factory. Internally, this allows it to re-match the current request using theGET
method; the middleware never generates its own response any longer. -
#58 changes the logic of
Route::allowsMethod()
; it no longer returnstrue
forHEAD
orOPTIONS
requests if they are not explicitly in the list of allowed methods. -
#59 changes the behavior of the
Route
constructor: it now raises an exception if the list of HTTP methods provided to it is empty. Routes MUST have one or more HTTP methods associated. -
#60 changes the behavior of the
RouteResult::getAllowedMethods()
to allow a nullable return value; this will returnnull
if all methods are allowed.
Removed
-
#48 removes the method
Zend\Expressive\Router\RouteResult::getMatchedMiddleware()
; the method is no longer necessary, as the class now implementsMiddlewareInterface
and proxies to the underlying route. -
#58 removes the following methods from
Route
, as they are no longer used:implicitHead()
implicitOptions()
Fixed
-
#53 fixes logic in the
ImplicitHeadMiddleware
andImplicitOptionsMiddleware
classes with regards to how they determine that an implicitHEAD
orOPTIONS
request (respectively) has occurred. -
#66 improves the exception message raised when a route conflict is detected to include the path, HTTP methods, and name (if available).
zend-expressive-router 3.0.0rc6
This change contains a fix to the integration tests to refer to RouteMiddleware
instead of PathBasedRoutingMiddleware
.
Cumulative changes for the 3.0.0 release, including those for previous alpha and RC releases:
Added
-
#50 adds
Zend\Expressive\Router\ConfigProvider
, and registers it with the package. The class defines and returns the initial dependencies for the package. -
#50 adds factory classes for all shipped middleware. In some cases (
ImplicitHeadMiddleware
,ImplicitOptionsMiddleware
, andMethodNotAllowedMiddleware
), these rely on additional services that you will need to configure within your application in order to work properly. See each factory for details. -
#47, #50, and #64 add the
Zend\Expressive\Router\RouteCollector
class, which composes aRouterInterface
, and provides methods for defining and creating path+method based routes. It exposes the following methods:route(string $path, MiddlewareInterface $middleware, array $methods = null, string $name = null) : Route
get(string $path, MiddlewareInterface $middleware, string $name = null) : Route
post(string $path, MiddlewareInterface $middleware, string $name = null) : Route
put(string $path, MiddlewareInterface $middleware, string $name = null) : Route
patch(string $path, MiddlewareInterface $middleware, string $name = null) : Route
delete(string $path, MiddlewareInterface $middleware, string $name = null) : Route
any(string $path, MiddlewareInterface $middleware, string $name = null) : Route
-
#48 and #50 adds
Zend\Expressive\Router\Middleware\MethodNotAllowedMiddleware
. This middleware checks if the request composes aRouteResult
, and, if so, if it is due to a method failure. If neither of those conditions is true, it delegates processing of the request to the handler. Otherwise, it uses a composed response prototype in order to create a "405 Method Not Allowed" response, with anAllow
header containing the list of allowed request methods. -
#49 and #50 add the class
Zend\Expressive\Router\Middleware\ImplicitHeadMiddleware
. This middleware will answer aHEAD
request for a given route. If no route was matched, or the route allowsHEAD
requests, it delegates to the handler. If the route does not allow aGET
request, it returns an empty response, as composed in the middleware. Otherwise, it issues aGET
request to the handler, indicating the method was forwarded for aHEAD
request, and then returns the response with an empty body. -
#49 and #50 add the class
Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware
. This middleware handlesOPTIONS
requests when a route result is present and the route does not explicitly supportOPTIONS
(and otherwise delegates to the handler). In those conditions, it returns the response composed in the middleware, with anAllow
header indicating the allowed methods. -
#53 and #58 add an abstract test case,
Zend\Expressive\Router\Test\ImplicitMethodsIntegrationTest
. Implementors ofRouterInterface
should extend this class in their own test suite to ensure that they create appropriateRouteResult
instances for each of the following cases:HEAD
request called and matches one or more known routes, but the method is not defined for any of them.OPTIONS
request called and matches one or more known routes, but the method is not defined for any of them.- Request matches one or more known routes, but the method is not allowed.
In particular, these tests ensure that implementations marshal the list of allowed HTTP methods correctly in the latter two cases.
Changed
-
#41 updates the
Route
class to provide typehints for all arguments and return values. Typehints were generally derived from the existing annotations, with the following items of particular note:- The constructor
$middleware
argument typehints on the PSR-15MiddlewareInterface
. - The
getMiddleware()
method now explicitly returns a PSR-15MiddlewareInterface
instance. getAllowedMethods()
now returns a nullablearray
.
- The constructor
-
#41 and #43 update the
RouteResult
class to add typehints for all arguments and return values, where possible. Typehints were generally derived from the existing annotations, with the following items of particular note:- The
$methods
argument tofromRouteFailure()
is now a nullable array (withnull
representing the fact that any method is allowed), without a default value. You must provide a value when creating a route failure. getAllowedMethods()
will now return['*']
when any HTTP method is allowed; this will evaluate to a validAllows
header value, and is the recommended value when any HTTP method is allowed.
- The
-
#41 updates the
RouteInterface
to add typehints for all arguments and return values. In particular, thse are now:addRoute(Route $route) : void
match(Psr\Http\Message\ServerRequestInterface $request) : RouteResult
generateUri(string $name, array $substitutions = [], array $options = []) : string
-
#47 modifies the
RouteMiddleware::$router
property to make itprotected
visibility, allowing extensions to work with it. -
#48 modifies
Zend\Expressive\Router\Route
to implement the PSR-15MiddlewareInterface
. The newprocess()
method proxies to the composed middleware. -
#48 modifies
Zend\Expressive\Router\RouteResult
to implement the PSR-15MiddlewareInterface
. The newprocess()
method proxies to the composedRoute
instance in the case of a success, and otherwise delegates to the passed handler instance. -
#48 modifies
Zend\Expressive\Router\DispatchMiddleware
to process theRouteResult
directly, instead of pulling middleware from it. -
#50 renames
Zend\Expressive\Router\RouteMiddleware
toZend\Expressive\Router\Middleware\RouteMiddleware
. -
#50 renames
Zend\Expressive\Router\DispatchMiddleware
toZend\Expressive\Router\Middleware\DispatchMiddleware
. -
#58 changes the constructor of
ImplicitHeadMiddleware
to accept aRouterInterface
instead of a response factory. Internally, this allows it to re-match the current request using theGET
method; the middleware never generates its own response any longer. -
#58 changes the logic of
Route::allowsMethod()
; it no longer returnstrue
forHEAD
orOPTIONS
requests if they are not explicitly in the list of allowed methods. -
#59 changes the behavior of the
Route
constructor: it now raises an exception if the list of HTTP methods provided to it is empty. Routes MUST have one or more HTTP methods associated. -
#60 changes the behavior of the
RouteResult::getAllowedMethods()
to allow a nullable return value; this will returnnull
if all methods are allowed.
Removed
-
#48 removes the method
Zend\Expressive\Router\RouteResult::getMatchedMiddleware()
; the method is no longer necessary, as the class now implementsMiddlewareInterface
and proxies to the underlying route. -
#58 removes the following methods from
Route
, as they are no longer used:implicitHead()
implicitOptions()
Fixed
- #53 fixes logic in the
ImplicitHeadMiddleware
andImplicitOptionsMiddleware
classes with regards to how they determine that an implicitHEAD
orOPTIONS
request (respectively) has occurred.
zend-expressive-router 3.0.0rc5
This release candidate contains one breaking change, deemed necessary before a stable release: Zend\Expressive\Router\Middleware\PathBasedRoutingMiddleware
has been renamed to Zend\Expressive\Router\RouteCollector
, and no longer extends Zend\Expressive\Router\Middleware\RouteMiddleware
.
Users can use the RouteMiddleware
within their applications using the same RouterInterface
implementation as used in RouteCollector
; the latter can then be used to create Route
instances and inject them in the composed router.
Cumulative changes for the 3.0.0 release, including those for previous alpha and RC releases:
Added
-
#50 adds
Zend\Expressive\Router\ConfigProvider
, and registers it with the package. The class defines and returns the initial dependencies for the package. -
#50 adds factory classes for all shipped middleware. In some cases (
ImplicitHeadMiddleware
,ImplicitOptionsMiddleware
, andMethodNotAllowedMiddleware
), these rely on additional services that you will need to configure within your application in order to work properly. See each factory for details. -
#47, #50, and #64 add the
Zend\Expressive\Router\RouteCollector
class, which composes aRouterInterface
, and provides methods for defining and creating path+method based routes. It exposes the following methods:route(string $path, MiddlewareInterface $middleware, array $methods = null, string $name = null) : Route
get(string $path, MiddlewareInterface $middleware, string $name = null) : Route
post(string $path, MiddlewareInterface $middleware, string $name = null) : Route
put(string $path, MiddlewareInterface $middleware, string $name = null) : Route
patch(string $path, MiddlewareInterface $middleware, string $name = null) : Route
delete(string $path, MiddlewareInterface $middleware, string $name = null) : Route
any(string $path, MiddlewareInterface $middleware, string $name = null) : Route
-
#48 and #50 adds
Zend\Expressive\Router\Middleware\MethodNotAllowedMiddleware
. This middleware checks if the request composes aRouteResult
, and, if so, if it is due to a method failure. If neither of those conditions is true, it delegates processing of the request to the handler. Otherwise, it uses a composed response prototype in order to create a "405 Method Not Allowed" response, with anAllow
header containing the list of allowed request methods. -
#49 and #50 add the class
Zend\Expressive\Router\Middleware\ImplicitHeadMiddleware
. This middleware will answer aHEAD
request for a given route. If no route was matched, or the route allowsHEAD
requests, it delegates to the handler. If the route does not allow aGET
request, it returns an empty response, as composed in the middleware. Otherwise, it issues aGET
request to the handler, indicating the method was forwarded for aHEAD
request, and then returns the response with an empty body. -
#49 and #50 add the class
Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware
. This middleware handlesOPTIONS
requests when a route result is present and the route does not explicitly supportOPTIONS
(and otherwise delegates to the handler). In those conditions, it returns the response composed in the middleware, with anAllow
header indicating the allowed methods. -
#53 and #58 add an abstract test case,
Zend\Expressive\Router\Test\ImplicitMethodsIntegrationTest
. Implementors ofRouterInterface
should extend this class in their own test suite to ensure that they create appropriateRouteResult
instances for each of the following cases:HEAD
request called and matches one or more known routes, but the method is not defined for any of them.OPTIONS
request called and matches one or more known routes, but the method is not defined for any of them.- Request matches one or more known routes, but the method is not allowed.
In particular, these tests ensure that implementations marshal the list of allowed HTTP methods correctly in the latter two cases.
Changed
-
#41 updates the
Route
class to provide typehints for all arguments and return values. Typehints were generally derived from the existing annotations, with the following items of particular note:- The constructor
$middleware
argument typehints on the PSR-15MiddlewareInterface
. - The
getMiddleware()
method now explicitly returns a PSR-15MiddlewareInterface
instance. getAllowedMethods()
now returns a nullablearray
.
- The constructor
-
#41 and #43 update the
RouteResult
class to add typehints for all arguments and return values, where possible. Typehints were generally derived from the existing annotations, with the following items of particular note:- The
$methods
argument tofromRouteFailure()
is now a nullable array (withnull
representing the fact that any method is allowed), without a default value. You must provide a value when creating a route failure. getAllowedMethods()
will now return['*']
when any HTTP method is allowed; this will evaluate to a validAllows
header value, and is the recommended value when any HTTP method is allowed.
- The
-
#41 updates the
RouteInterface
to add typehints for all arguments and return values. In particular, thse are now:addRoute(Route $route) : void
match(Psr\Http\Message\ServerRequestInterface $request) : RouteResult
generateUri(string $name, array $substitutions = [], array $options = []) : string
-
#47 modifies the
RouteMiddleware::$router
property to make itprotected
visibility, allowing extensions to work with it. -
#48 modifies
Zend\Expressive\Router\Route
to implement the PSR-15MiddlewareInterface
. The newprocess()
method proxies to the composed middleware. -
#48 modifies
Zend\Expressive\Router\RouteResult
to implement the PSR-15MiddlewareInterface
. The newprocess()
method proxies to the composedRoute
instance in the case of a success, and otherwise delegates to the passed handler instance. -
#48 modifies
Zend\Expressive\Router\DispatchMiddleware
to process theRouteResult
directly, instead of pulling middleware from it. -
#50 renames
Zend\Expressive\Router\RouteMiddleware
toZend\Expressive\Router\Middleware\RouteMiddleware
. -
#50 renames
Zend\Expressive\Router\DispatchMiddleware
toZend\Expressive\Router\Middleware\DispatchMiddleware
. -
#58 changes the constructor of
ImplicitHeadMiddleware
to accept aRouterInterface
instead of a response factory. Internally, this allows it to re-match the current request using theGET
method; the middleware never generates its own response any longer. -
#58 changes the logic of
Route::allowsMethod()
; it no longer returnstrue
forHEAD
orOPTIONS
requests if they are not explicitly in the list of allowed methods. -
#59 changes the behavior of the
Route
constructor: it now raises an exception if the list of HTTP methods provided to it is empty. Routes MUST have one or more HTTP methods associated. -
#60 changes the behavior of the
RouteResult::getAllowedMethods()
to allow a nullable return value; this will returnnull
if all methods are allowed.
Removed
-
#48 removes the method
Zend\Expressive\Router\RouteResult::getMatchedMiddleware()
; the method is no longer necessary, as the class now implementsMiddlewareInterface
and proxies to the underlying route. -
#58 removes the following methods from
Route
, as they are no longer used:implicitHead()
implicitOptions()
Fixed
zend-expressive-router 2.4.1
Added
- Nothing.
Changed
- #63 improves the deprecation notice raised by the
Zend\Expressive\Router\Route
constructor when non-middleware interface implementations are passed for the$middleware
argument. The message not contains the path, HTTP methods, and middleware type that were used to create theRoute
instance.
Deprecated
- Nothing.
Removed
- Nothing.
Fixed
- Nothing.
zend-expressive-router 2.4.0
Added
-
#54 adds the middleware
Zend\Expressive\Router\Middleware\DispatchMiddleware
andZend\Expressive\Router\Middleware\RouteMiddleware
. These are the same as the versions shipped in 2.3.0, but under a new namespace. -
#55 adds
Zend\Expressive\Router\Middleware\ImplicitHeadMiddleware
. It is imported from zend-expressive, and implements the same functionality. -
#55 adds
Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware
. It is imported from zend-expressive, and implements the same functionality. -
#57 adds the following factories for use with PSR-11 containers:
Zend\Expressive\Router\Middleware\DispatchMiddlewareFactory
Zend\Expressive\Router\Middleware\ImplicitHeadMiddlewareFactory
Zend\Expressive\Router\Middleware\ImplicitOptionsMiddlewareFactory
Zend\Expressive\Router\Middleware\RouteMiddlewareFactory
-
#57 adds
Zend\Expressive\Router\ConfigProvider
, mapping the above factories to their respective middleware, and exposing it to zend-component-installer via the package definition.
Changed
- Nothing.
Deprecated
-
#56 deprecates the method
Zend\Expressive\RouteResult::getMatchedMiddleware()
, as it will be removed in version 3. If you need access to the middleware, usegetMatchedRoute()->getMiddleware()
. (In version 3, theRouteResult
is middleware, and will proxy to it.) -
#56 deprecates passing non-MiddlewareInterface instances to the constructor of
Zend\Expressive\Route
. The class now triggers a deprecation notice when this occurs, indicating the changes the developer needs to make. -
#54 deprecates the middleware
Zend\Expressive\Router\DispatchMiddleware
andZend\Expressive\Router\RouteMiddleware
. The final versions in the v3 release will be under theZend\Expressive\Router\Middleware
namespace; please use those instead. -
#55 deprecates two methods in
Zend\Expressive\Router\Route
:implicitHead()
implicitOptions()
Starting in 3.0.0, implementations will need to return route result failures that include all allowed methods when matching
HEAD
orOPTIONS
implicitly.
Removed
- Nothing.
Fixed
- Nothing.