Skip to content

3.0.0alpha2

@weierophinney weierophinney tagged this 13 Feb 20:44
Based on https://github.com/zendframework/zend-expressive-router/releases/tag/3.0.0alpha2 (commit 5b60fe58638f6522908f452c0f32710e2db428e9 in this repo)

Cumulative changes for the 3.0.0 release, including those for 3.0.0alpha1.

Added
-----

- [zendframework/zend-expressive-router#50](https://github.com/zendframework/zend-expressive-router/pull/50) adds
  `Mezzio\Router\ConfigProvider`, and registers it with the package.
  The class defines and returns the initial dependencies for the package.

- [zendframework/zend-expressive-router#50](https://github.com/zendframework/zend-expressive-router/pull/50) adds
  factory classes for all shipped middleware. In some cases
  (`ImplicitHeadMiddleware`, `ImplicitOptionsMiddleware`, and
  `MethodNotAllowedMiddleware`, these rely on virtual services that you will
  need to configure within your application in order to work properly. See each
  factory for details.

- [zendframework/zend-expressive-router#47](https://github.com/zendframework/zend-expressive-router/pull/47) and
  [zendframework/zend-expressive-router#50](https://github.com/zendframework/zend-expressive-router/pull/50) add
  the middleware `Mezzio\Router\Middleware\PathBasedRoutingMiddleware`,
  which extends the `RouteMiddleware` to add 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`

- [zendframework/zend-expressive-router#48](https://github.com/zendframework/zend-expressive-router/pull/48) and
  [zendframework/zend-expressive-router#50](https://github.com/zendframework/zend-expressive-router/pull/50) adds
  `Mezzio\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.

- [zendframework/zend-expressive-router#49](https://github.com/zendframework/zend-expressive-router/pull/49) and
  [zendframework/zend-expressive-router#50](https://github.com/zendframework/zend-expressive-router/pull/50) add
  the class `Mezzio\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.

- [zendframework/zend-expressive-router#49](https://github.com/zendframework/zend-expressive-router/pull/49) and
  [zendframework/zend-expressive-router#50](https://github.com/zendframework/zend-expressive-router/pull/50) add
  the class `Mezzio\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.

- [zendframework/zend-expressive-router#39](https://github.com/zendframework/zend-expressive-router/pull/39) and
  [zendframework/zend-expressive-router#45](https://github.com/zendframework/zend-expressive-router/pull/45) add
  PSR-15 `psr/http-server-middleware` support.

Changed
-------

- [zendframework/zend-expressive-router#41](https://github.com/zendframework/zend-expressive-router/pull/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`.

- [zendframework/zend-expressive-router#41](https://github.com/zendframework/zend-expressive-router/pull/41) and
  [zendframework/zend-expressive-router#43](https://github.com/zendframework/zend-expressive-router/pull/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.

- [zendframework/zend-expressive-router#41](https://github.com/zendframework/zend-expressive-router/pull/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`

- [zendframework/zend-expressive-router#47](https://github.com/zendframework/zend-expressive-router/pull/47)
  modifies the `RouteMiddleware::$router` property to make it `protected`
  visibility, allowing extensions to work with it.

- [zendframework/zend-expressive-router#48](https://github.com/zendframework/zend-expressive-router/pull/48)
  modifies `Mezzio\Router\Route` to implement the PSR-15
  `MiddlewareInterface`. The new `process()` method proxies to the composed
  middleware.

- [zendframework/zend-expressive-router#48](https://github.com/zendframework/zend-expressive-router/pull/48)
  modifies `Mezzio\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.

- [zendframework/zend-expressive-router#48](https://github.com/zendframework/zend-expressive-router/pull/48)
  modifies `Mezzio\Router\DispatchMiddleware` to process the
  `RouteResult` directly, instead of pulling middleware from it.

- [zendframework/zend-expressive-router#50](https://github.com/zendframework/zend-expressive-router/pull/50) renames
  `Mezzio\Router\RouteMiddleware` to
  `Mezzio\Router\Middleware\RouteMiddleware`.

- [zendframework/zend-expressive-router#50](https://github.com/zendframework/zend-expressive-router/pull/50) renames
  `Mezzio\Router\DispatchMiddleware` to
  `Mezzio\Router\Middleware\DispatchMiddleware`.

Deprecated
----------

- Nothing.

Removed
-------

- [zendframework/zend-expressive-router#39](https://github.com/zendframework/zend-expressive-router/pull/39) and
  [zendframework/zend-expressive-router#41](https://github.com/zendframework/zend-expressive-router/pull/41) remove
  PHP 5.6 and PHP 7.0 support.

- [zendframework/zend-expressive-router#48](https://github.com/zendframework/zend-expressive-router/pull/48)
  removes the method `Mezzio\Router\RouteResult::getMatchedMiddleware()`;
  the method is no longer necessary, as the class now implements
  `MiddlewareInterface` and proxies to the underlying route.

Fixed
-----

- Nothing.
Assets 2