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

Commit 47620f2

Browse files
committed
Merges develop into release-3.0.0 in preparation for 2.2.0 release
Conflicts: .travis.yml CHANGELOG.md composer.json composer.lock mkdocs.yml src/AppFactory.php src/Application.php src/ConfigProvider.php src/Container/ApplicationConfigInjectionDelegator.php src/Container/ApplicationFactory.php src/Container/NotFoundDelegateFactory.php src/Container/ResponseFactoryFactory.php src/Container/StreamFactoryFactory.php src/Delegate/NotFoundDelegate.php src/Emitter/EmitterStack.php src/Handler/NotFoundHandler.php src/IsCallableInteropMiddlewareTrait.php src/MarshalMiddlewareTrait.php src/Middleware/DispatchMiddleware.php src/Middleware/ImplicitHeadMiddleware.php src/Middleware/ImplicitOptionsMiddleware.php src/Middleware/NotFoundHandler.php src/Middleware/RouteMiddleware.php test/AppFactoryTest.php test/Application/MarshalMiddlewareTraitTest.php test/ApplicationTest.php test/ConfigProviderTest.php test/Container/ApplicationConfigInjectionDelegatorTest.php test/Container/ApplicationFactoryTest.php test/Container/ResponseFactoryFactoryTest.php test/Container/StreamFactoryFactoryTest.php test/Handler/NotFoundHandlerTest.php test/Middleware/ImplicitHeadMiddlewareTest.php test/Middleware/ImplicitOptionsMiddlewareTest.php
2 parents a36bc3a + 073a4d6 commit 47620f2

16 files changed

+582
-186
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ install:
4343
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
4444
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
4545
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
46+
- if [[ $TEST_COVERAGE == 'true' ]]; then cp phpunit.xml.dist-coverage phpunit.xml.dist ; fi
4647
- stty cols 120 && composer show
48+
- cat phpunit.xml.dist
4749

4850
script:
4951
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi

CHANGELOG.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,114 @@ All notable changes to this project will be documented in this file, in reverse
654654

655655
- Nothing.
656656

657+
## 2.2.0 - 2018-03-12
658+
659+
### Added
660+
661+
- [#581](https://github.com/zendframework/zend-expressive/pull/581) adds the
662+
class `Zend\Expressive\ConfigProvider`, and exposes it to the
663+
zend-component-installer Composer plugin. We recommend updating your
664+
`config/config.php` to reference it, as well as the
665+
`Zend\Expressive\Router\ConfigProvider` shipped with zend-expressive-router
666+
versions 2.4 and up.
667+
668+
- [#581](https://github.com/zendframework/zend-expressive/pull/581) adds the
669+
class `Zend\Expressive\Container\ApplicationConfigInjectionDelegator`. The
670+
class can act as a delegator factory, and, when enabled, will inject routes
671+
and pipeline middleware defined in configuration.
672+
673+
Additionally, the class exposes two static methods:
674+
675+
- `injectPipelineFromConfig(Application $app, array $config)`
676+
- `injectRoutesFromConfig(Application $app, array $config)`
677+
678+
These may be called to modify an `Application` instance based on an array of
679+
configuration. See thd documentation for more details.
680+
681+
- [#581](https://github.com/zendframework/zend-expressive/pull/581) adds the
682+
class `Zend\Expressive\Handler\NotFoundHandler`; the class takes over the
683+
functionality previously provided in `Zend\Expressive\Delegate\NotFoundDelegate`.
684+
685+
### Changed
686+
687+
- [#581](https://github.com/zendframework/zend-expressive/pull/581) updates the
688+
minimum supported zend-stratigility version to 2.2.0.
689+
690+
- [#581](https://github.com/zendframework/zend-expressive/pull/581) updates the
691+
minimum supported zend-expressive-router version to 2.4.0.
692+
693+
### Deprecated
694+
695+
- [#581](https://github.com/zendframework/zend-expressive/pull/581) deprecates
696+
the following classes and traits:
697+
698+
- `Zend\Expressive\AppFactory`: if you are using this, you will need to switch
699+
to direct usage of `Zend\Expressive\Application` or a
700+
`Zend\Stratigility\MiddlewarePipe` instance.
701+
702+
- `Zend\Expressive\ApplicationConfigInjectionTrait`: if you are using it, it is
703+
marked internal, and deprecated; it will be removed in version 3.
704+
705+
- `Zend\Expressive\Container\NotFoundDelegateFactory`: the `NotFoundDelegate`
706+
will be renamed to `Zend\Expressive\Handler\NotFoundHandler` in version 3,
707+
making this factory obsolete.
708+
709+
- `Zend\Expressive\Delegate\NotFoundDelegate`: this class becomes
710+
`Zend\Expressive\Handler\NotFoundHandler` in v3, and the new class is added in
711+
version 2.2 as well.
712+
713+
- `Zend\Expressive\Emitter\EmitterStack`: the emitter concept is extracted from
714+
zend-diactoros to a new component, zend-httphandlerrunner. This latter
715+
component is used in version 3, and defines the `EmitterStack` class. Unless
716+
you are extending it or interacting with it directly, this change should not
717+
affect you; the `Zend\Diactoros\Response\EmitterInterface` service will be
718+
directed to the new class in that version.
719+
720+
- `Zend\Expressive\IsCallableInteropMiddlewareTrait`: if you are using it, it is
721+
marked internal, and deprecated; it will be removed in version 3.
722+
723+
- `Zend\Expressive\MarshalMiddlewareTrait`: if you are using it, it is marked
724+
internal, and deprecated; it will be removed in version 3.
725+
726+
- `Zend\Expressive\Middleware\DispatchMiddleware`: this functionality has been
727+
moved to zend-expressive-router, under the `Zend\Expressive\Router\Middleware`
728+
namespace.
729+
730+
- `Zend\Expressive\Middleware\ImplicitHeadMiddleware`: this functionality has been
731+
moved to zend-expressive-router, under the `Zend\Expressive\Router\Middleware`
732+
namespace.
733+
734+
- `Zend\Expressive\Middleware\ImplicitOptionsMiddleware`: this functionality has been
735+
moved to zend-expressive-router, under the `Zend\Expressive\Router\Middleware`
736+
namespace.
737+
738+
- `Zend\Expressive\Middleware\NotFoundHandler`: this will be removed in
739+
version 3, where you can instead pipe `Zend\Expressive\Handler\NotFoundHandler`
740+
directly instead.
741+
742+
- `Zend\Expressive\Middleware\RouteMiddleware`: this functionality has been
743+
moved to zend-expressive-router, under the `Zend\Expressive\Router\Middleware`
744+
namespace.
745+
746+
- [#581](https://github.com/zendframework/zend-expressive/pull/581) deprecates
747+
the following methods from `Zend\Expressive\Application`:
748+
- `pipeRoutingMiddleware()`
749+
- `pipeDispatchMiddleware()`
750+
- `getContainer()`: this method is removed in version 3; container access will only be via the bootstrap.
751+
- `getDefaultDelegate()`: the concept of a default delegate is removed in version 3.
752+
- `getEmitter()`: emitters move to a different collaborator in version 3.
753+
- `injectPipelineFromConfig()` andd `injectRoutesFromConfig()` are methods
754+
defined by the `ApplicationConfigInjectionTrait`, which will be removed in
755+
version 3. Use the `ApplicationConfigInjectionDelegator` instead.
756+
757+
### Removed
758+
759+
- Nothing.
760+
761+
### Fixed
762+
763+
- Nothing.
764+
657765
## 2.1.1 - 2018-03-09
658766

659767
### Added

docs/book/v2/cookbook/autowiring-routes-and-pipelines.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,35 @@ delegator factory by wiring it into their own configuration.
208208
occur in exactly _one_ delegator factory.
209209
- Distributable packages should create a delegator factory for _routes only_,
210210
but _should not_ register the delegator factory by default.
211+
212+
## ApplicationConfigInjectionDelegator
213+
214+
- Since version 2.2
215+
216+
`Zend\Expressive\Container\ApplicationConfigInjectionDelegator` allows you to
217+
define configuration that is then used to call `pipe()` or the various routing
218+
methods of `Zend\Expressive\Application`. This is particularly useful for
219+
injecting _routes_.
220+
221+
The format of routes configuration is as follows:
222+
223+
```php
224+
return [
225+
'routes' => [
226+
[
227+
'path' => '/path/to/match',
228+
'middleware' => 'Middleware Service Name',
229+
'allowed_methods' => ['GET', 'POST', 'PATCH'],
230+
'options' => [
231+
'stuff' => 'to',
232+
'pass' => 'to',
233+
'the' => 'underlying router',
234+
],
235+
],
236+
// etc.
237+
],
238+
];
239+
```
240+
241+
All your various modules could provide route configuration, and you could then
242+
use a single delegator to add all of them at once.

docs/book/v2/features/application.md

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,50 +34,32 @@ As noted at the start of this document, we provide several ways to create an
3434
If you wish to manually instantiate the `Application` instance, it has the
3535
following constructor:
3636

37-
- Expressive 2.X:
38-
39-
```php
40-
/**
41-
* @param Zend\Expressive\Router\RouterInterface $router
42-
* @param null|Psr\Container\ContainerInterface $container IoC container from which to pull services, if any.
43-
* @param null|Interop\Http\ServerMiddleware\DelegateInterface $defaultDelegate
44-
* Delegate to invoke when the internal middleware pipeline is exhausted
45-
* without returning a response.
46-
* @param null|Zend\Diactoros\Response\EmitterInterface $emitter Emitter to use when `run()` is
47-
* invoked.
48-
*/
49-
public function __construct(
50-
Zend\Expressive\Router\RouterInterface $router,
51-
Psr\Container\ContainerInterface $container = null,
52-
Interop\Http\ServerMiddleware\DelegateInterface $defaultDelegate = null,
53-
Zend\Diactoros\Response\EmitterInterface $emitter = null
54-
);
55-
```
56-
57-
- Expressive 1.X:
58-
59-
```php
60-
/**
61-
* @param Zend\Expressive\Router\RouterInterface $router
62-
* @param null|Psr\Container\ContainerInterface $container IoC container from which to pull services, if any.
63-
* @param null|callable $finalHandler Final handler to use when $out is not
64-
* provided on invocation.
65-
* @param null|Zend\Diactoros\Response\EmitterInterface $emitter Emitter to use when `run()` is
66-
* invoked.
67-
*/
68-
public function __construct(
69-
Zend\Expressive\Router\RouterInterface $router,
70-
Psr\Container\ContainerInterface $container = null,
71-
callable $finalHandler = null,
72-
Zend\Diactoros\Response\EmitterInterface $emitter = null
73-
);
74-
```
37+
```php
38+
/**
39+
* @param Zend\Expressive\Router\RouterInterface $router
40+
* @param null|Psr\Container\ContainerInterface $container IoC container from which to pull services, if any.
41+
* @param null|Interop\Http\ServerMiddleware\DelegateInterface $defaultDelegate
42+
* Delegate to invoke when the internal middleware pipeline is exhausted
43+
* without returning a response.
44+
* @param null|Zend\Diactoros\Response\EmitterInterface $emitter Emitter to use when `run()` is
45+
* invoked.
46+
*/
47+
public function __construct(
48+
Zend\Expressive\Router\RouterInterface $router,
49+
Psr\Container\ContainerInterface $container = null,
50+
Interop\Http\ServerMiddleware\DelegateInterface $defaultDelegate = null,
51+
Zend\Diactoros\Response\EmitterInterface $emitter = null
52+
);
53+
```
7554

7655
If no container is provided at instantiation, then all routed and piped
7756
middleware **must** be provided as callables.
7857

7958
### AppFactory
8059

60+
- Deprecated since version 2.2; instantiate `Application` directly and/or use a
61+
`Zend\Stratigility\MiddlewarePipe` instance instead.
62+
8163
`Zend\Expressive\AppFactory` provides a convenience layer for creating an
8264
`Application` instance; it makes the assumption that you will use defaults in
8365
most situations, and likely only change which container and/or router you wish
@@ -210,10 +192,10 @@ Read the section on [piping vs routing](router/piping.md) for more information.
210192

211193
### Registering routing and dispatch middleware
212194

213-
Routing is accomplished via a dedicated middleware method,
214-
`Application::routeMiddleware()`; similarly, dispatching of routed middleware
215-
has a corresponding instance middleware method, `Application::dispatchMiddleware()`.
216-
Each can be piped/registered with other middleware platforms if desired.
195+
Routing is accomplished via dedicated middleware, `Zend\Expressive\Middleware\RouteMiddleware`;
196+
similarly, dispatching of routed middleware has a corresponding middleware,
197+
`Zend\Expressive\Middleware\DispatchMiddleware`. Each can be piped/registered
198+
with other middleware platforms if desired.
217199

218200
These methods **MUST** be piped to the application so that the application will
219201
route and dispatch routed middleware. This is done using the following methods:
@@ -226,6 +208,18 @@ $app->pipeDispatchMiddleware();
226208
See the section on [piping](router/piping.md) to see how you can register
227209
non-routed middleware and create layered middleware applications.
228210

211+
> #### Changed in version 2.2
212+
>
213+
> Starting in version 2.2, the methods `pipeRoutingMiddleware` and
214+
> `pipeDispatchMiddleware` are deprecated in favor of piping the middleware
215+
> manually.
216+
>
217+
> Additionally, the middleware has been ported to the zend-expressive-router
218+
> package, under the namespace `Zend\Expressive\Router\Middleware`. We suggest
219+
> piping them by service name. Please see our [migration documentation](../reference/migration-to-v2-2.md#routing-and-dispatch-middleware)
220+
> for more details, and for information on how to automatically update your
221+
> application.
222+
229223
## Retrieving dependencies
230224

231225
As noted in the intro, the `Application` class has several dependencies. Some of
@@ -237,7 +231,7 @@ methods for retrieving them. They include:
237231
- `getEmitter()`: returns the composed
238232
[emitter](https://docs.zendframework.com/zend-diactoros/emitting-responses/),
239233
typically a `Zend\Expressive\Emitter\EmitterStack` instance.
240-
- `getDefaultDelegate()`: (Since 2.0) retrieves the default delegate to use when the internal middleware pipeline is exhausted without returning a response. If none is provided at instantiation, this method will do one of the following:
234+
- `getDefaultDelegate()`: retrieves the default delegate to use when the internal middleware pipeline is exhausted without returning a response. If none is provided at instantiation, this method will do one of the following:
241235
- If no container is composed, instanatiates a
242236
`Zend\Expressive\Delegate\NotFoundDelegate` using the composed response
243237
prototype only.
@@ -247,10 +241,12 @@ methods for retrieving them. They include:
247241
the composed container, and uses the value created.
248242
- If a container is composed and contains the `Zend\Expressive\Delegate\DefaultDelegate`
249243
service, it returns that.
250-
- `getFinalHandler(ResponseInterface $response = null)`: (**REMOVED in version 2.0**)
251-
retrieves the final handler instance. This is middleware with the signature
252-
`function ($request, $response, $error = null)`, and it is invoked when the
253-
middleware pipeline queue is depleted and no response has been returned.
244+
245+
> #### Deprecated
246+
>
247+
> Each of the above methods are deprecated starting in version 2.2, and will be
248+
> removed in version 3.0.
249+
254250

255251
## Executing the application: run()
256252

docs/book/v2/features/emitters.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,13 @@ $stack->push($emitterInstance);
3939

4040
As a stack, execution is in LIFO (last in, first out) order; the first emitter
4141
on the stack will be evaluated last.
42+
43+
> ## Deprecated with version 2.2
44+
>
45+
> Starting in version 2.2, the `EmitterStack` is deprecated, and moved, along with the
46+
> zend-diactoros `EmitterInterface` and implementations, to a new package,
47+
> [zend-httphandlerrunner](https://docs.zendframework.com/zend-httphandlerrunner).
48+
>
49+
> The interface and the `EmitterStack` are roughly identical to what is present in
50+
> version 2; if you are defining a `Zend\Diactoros\Emitter\EmitterInterface`
51+
> service of your own, you will need to update it in that version.

0 commit comments

Comments
 (0)