Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Releases: zendframework/zend-expressive-router

zend-expressive-router 3.1.1

16 Oct 20:08
3.1.1
Compare
Choose a tag to compare

Added

  • #80 adds support for PHP 7.3.

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.

zend-expressive-router 3.1.0

05 Jun 15:28
Compare
Choose a tag to compare

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

10 May 14:09
Compare
Choose a tag to compare

Added

  • Nothing.

Changed

  • Nothing.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • #74 fixes
    an issue with the ImplicitHeadMiddleware 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

21 Mar 16:51
Compare
Choose a tag to compare

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 the ImplicitOptionsMiddleware to attempt to return a response.

zend-expressive-router 3.0.1

19 Mar 15:43
Compare
Choose a tag to compare

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

15 Mar 16:02
Compare
Choose a tag to compare

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, and MethodNotAllowedMiddleware), 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 a RouterInterface, 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 a RouteResult, 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 an Allow header containing the list of allowed request methods.

  • #49 and #50 add the class Zend\Expressive\Router\Middleware\ImplicitHeadMiddleware. This middleware will answer a HEAD request for a given route. If no route was matched, or the route allows HEAD requests, it delegates to the handler. If the route does not allow a GET request, it returns an empty response, as composed in the middleware. Otherwise, it issues a GET request to the handler, indicating the method was forwarded for a HEAD request, and then returns the response with an empty body.

  • #49 and #50 add the class Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware. This middleware handles OPTIONS requests when a route result is present and the route does not explicitly support OPTIONS (and otherwise delegates to the handler). In those conditions, it returns the response composed in the middleware, with an Allow header indicating the allowed methods.

  • #39 and #45 add PSR-15 psr/http-server-middleware support.

  • #53 and #58 add an abstract test case, Zend\Expressive\Router\Test\ImplicitMethodsIntegrationTest. Implementors of RouterInterface should extend this class in their own test suite to ensure that they create appropriate RouteResult 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-15 MiddlewareInterface.
    • The getMiddleware() method now explicitly returns a PSR-15 MiddlewareInterface instance.
    • getAllowedMethods() now returns a nullable array.
  • #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 to fromRouteFailure() is now a nullable array (with null 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 valid Allows header value, and is the recommended value when any HTTP method is allowed.
  • #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 it protected visibility, allowing extensions to work with it.

  • #48 modifies Zend\Expressive\Router\Route to implement the PSR-15 MiddlewareInterface. The new process() method proxies to the composed middleware.

  • #48 modifies Zend\Expressive\Router\RouteResult to implement the PSR-15 MiddlewareInterface. The new process() method proxies to the composed Route instance in the case of a success, and otherwise delegates to the passed handler instance.

  • #48 modifies Zend\Expressive\Router\DispatchMiddleware to process the RouteResult directly, instead of pulling middleware from it.

  • #50 renames Zend\Expressive\Router\RouteMiddleware to Zend\Expressive\Router\Middleware\RouteMiddleware.

  • #50 renames Zend\Expressive\Router\DispatchMiddleware to Zend\Expressive\Router\Middleware\DispatchMiddleware.

  • #58 changes the constructor of ImplicitHeadMiddleware to accept a RouterInterface instead of a response factory. Internally, this allows it to re-match the current request using the GET method; the middleware never generates its own response any longer.

  • #58 changes the logic of Route::allowsMethod(); it no longer returns true for HEAD or OPTIONS 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 return null if all methods are allowed.

Removed

  • #39 and #41 remove PHP 5.6 and PHP 7.0 support.

  • #48 removes the method Zend\Expressive\Router\RouteResult::getMatchedMiddleware(); the method is no longer necessary, as the class now implements MiddlewareInterface 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 and ImplicitOptionsMiddleware classes with regards to how they determine that an implicit HEAD or OPTIONS 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

14 Mar 16:15
Compare
Choose a tag to compare

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, and MethodNotAllowedMiddleware), 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 a RouterInterface, 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 a RouteResult, 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 an Allow header containing the list of allowed request methods.

  • #49 and #50 add the class Zend\Expressive\Router\Middleware\ImplicitHeadMiddleware. This middleware will answer a HEAD request for a given route. If no route was matched, or the route allows HEAD requests, it delegates to the handler. If the route does not allow a GET request, it returns an empty response, as composed in the middleware. Otherwise, it issues a GET request to the handler, indicating the method was forwarded for a HEAD request, and then returns the response with an empty body.

  • #49 and #50 add the class Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware. This middleware handles OPTIONS requests when a route result is present and the route does not explicitly support OPTIONS (and otherwise delegates to the handler). In those conditions, it returns the response composed in the middleware, with an Allow header indicating the allowed methods.

  • #39 and #45 add PSR-15 psr/http-server-middleware support.

  • #53 and #58 add an abstract test case, Zend\Expressive\Router\Test\ImplicitMethodsIntegrationTest. Implementors of RouterInterface should extend this class in their own test suite to ensure that they create appropriate RouteResult 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-15 MiddlewareInterface.
    • The getMiddleware() method now explicitly returns a PSR-15 MiddlewareInterface instance.
    • getAllowedMethods() now returns a nullable array.
  • #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 to fromRouteFailure() is now a nullable array (with null 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 valid Allows header value, and is the recommended value when any HTTP method is allowed.
  • #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 it protected visibility, allowing extensions to work with it.

  • #48 modifies Zend\Expressive\Router\Route to implement the PSR-15 MiddlewareInterface. The new process() method proxies to the composed middleware.

  • #48 modifies Zend\Expressive\Router\RouteResult to implement the PSR-15 MiddlewareInterface. The new process() method proxies to the composed Route instance in the case of a success, and otherwise delegates to the passed handler instance.

  • #48 modifies Zend\Expressive\Router\DispatchMiddleware to process the RouteResult directly, instead of pulling middleware from it.

  • #50 renames Zend\Expressive\Router\RouteMiddleware to Zend\Expressive\Router\Middleware\RouteMiddleware.

  • #50 renames Zend\Expressive\Router\DispatchMiddleware to Zend\Expressive\Router\Middleware\DispatchMiddleware.

  • #58 changes the constructor of ImplicitHeadMiddleware to accept a RouterInterface instead of a response factory. Internally, this allows it to re-match the current request using the GET method; the middleware never generates its own response any longer.

  • #58 changes the logic of Route::allowsMethod(); it no longer returns true for HEAD or OPTIONS 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 return null if all methods are allowed.

Removed

  • #39 and #41 remove PHP 5.6 and PHP 7.0 support.

  • #48 removes the method Zend\Expressive\Router\RouteResult::getMatchedMiddleware(); the method is no longer necessary, as the class now implements MiddlewareInterface 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 and ImplicitOptionsMiddleware classes with regards to how they determine that an implicit HEAD or OPTIONS request (respectively) has occurred.

zend-expressive-router 3.0.0rc5

14 Mar 15:32
Compare
Choose a tag to compare

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, and MethodNotAllowedMiddleware), 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 a RouterInterface, 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 a RouteResult, 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 an Allow header containing the list of allowed request methods.

  • #49 and #50 add the class Zend\Expressive\Router\Middleware\ImplicitHeadMiddleware. This middleware will answer a HEAD request for a given route. If no route was matched, or the route allows HEAD requests, it delegates to the handler. If the route does not allow a GET request, it returns an empty response, as composed in the middleware. Otherwise, it issues a GET request to the handler, indicating the method was forwarded for a HEAD request, and then returns the response with an empty body.

  • #49 and #50 add the class Zend\Expressive\Router\Middleware\ImplicitOptionsMiddleware. This middleware handles OPTIONS requests when a route result is present and the route does not explicitly support OPTIONS (and otherwise delegates to the handler). In those conditions, it returns the response composed in the middleware, with an Allow header indicating the allowed methods.

  • #39 and #45 add PSR-15 psr/http-server-middleware support.

  • #53 and #58 add an abstract test case, Zend\Expressive\Router\Test\ImplicitMethodsIntegrationTest. Implementors of RouterInterface should extend this class in their own test suite to ensure that they create appropriate RouteResult 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-15 MiddlewareInterface.
    • The getMiddleware() method now explicitly returns a PSR-15 MiddlewareInterface instance.
    • getAllowedMethods() now returns a nullable array.
  • #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 to fromRouteFailure() is now a nullable array (with null 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 valid Allows header value, and is the recommended value when any HTTP method is allowed.
  • #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 it protected visibility, allowing extensions to work with it.

  • #48 modifies Zend\Expressive\Router\Route to implement the PSR-15 MiddlewareInterface. The new process() method proxies to the composed middleware.

  • #48 modifies Zend\Expressive\Router\RouteResult to implement the PSR-15 MiddlewareInterface. The new process() method proxies to the composed Route instance in the case of a success, and otherwise delegates to the passed handler instance.

  • #48 modifies Zend\Expressive\Router\DispatchMiddleware to process the RouteResult directly, instead of pulling middleware from it.

  • #50 renames Zend\Expressive\Router\RouteMiddleware to Zend\Expressive\Router\Middleware\RouteMiddleware.

  • #50 renames Zend\Expressive\Router\DispatchMiddleware to Zend\Expressive\Router\Middleware\DispatchMiddleware.

  • #58 changes the constructor of ImplicitHeadMiddleware to accept a RouterInterface instead of a response factory. Internally, this allows it to re-match the current request using the GET method; the middleware never generates its own response any longer.

  • #58 changes the logic of Route::allowsMethod(); it no longer returns true for HEAD or OPTIONS 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 return null if all methods are allowed.

Removed

  • #39 and #41 remove PHP 5.6 and PHP 7.0 support.

  • #48 removes the method Zend\Expressive\Router\RouteResult::getMatchedMiddleware(); the method is no longer necessary, as the class now implements MiddlewareInterface and proxies to the underlying route.

  • #58 removes the following methods from Route, as they are no longer used:

    • implicitHead()
    • implicitOptions()

Fixed

Read more

zend-expressive-router 2.4.1

08 Mar 19:29
Compare
Choose a tag to compare

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 the Route instance.

Deprecated

  • Nothing.

Removed

  • Nothing.

Fixed

  • Nothing.

zend-expressive-router 2.4.0

08 Mar 15:11
Compare
Choose a tag to compare

Added

  • #54 adds the middleware Zend\Expressive\Router\Middleware\DispatchMiddleware and Zend\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, use getMatchedRoute()->getMiddleware(). (In version 3, the RouteResult 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 and Zend\Expressive\Router\RouteMiddleware. The final versions in the v3 release will be under the Zend\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 or OPTIONS implicitly.

Removed

  • Nothing.

Fixed

  • Nothing.