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

Commit 789f772

Browse files
committed
Merge branch 'feature/stratigility-bc-breaks' into release-3.0.0
Close #543
2 parents c9924ec + 6514d54 commit 789f772

File tree

72 files changed

+2756
-3667
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2756
-3667
lines changed

CHANGELOG.md

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,225 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 3.0.0alpha2 - 2018-02-05
6+
7+
### Added
8+
9+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) adds support
10+
for the final PSR-15 interfaces, and explicitly depends on
11+
psr/http-server-middleware.
12+
13+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) adds a new
14+
class, `Zend\Expressive\MiddlewareContainer`. The class decorates a PSR-11
15+
`ContainerInterface`, and adds the following behavior:
16+
17+
- If a class is not in the container, but exists, `has()` will return `true`.
18+
- If a class is not in the container, but exists, `get()` will attempt to
19+
instantiate it, caching the instance locally if it is valid.
20+
- Any instance pulled from the container or directly instantiated is tested.
21+
If it is a PSR-15 `RequestHandlerInterface`, it will decorate it in a
22+
zend-stratigility `RequestHandlerMiddleware` instance. If the instance is
23+
not a PSR-15 `MiddlewareInterface`, the container will raise a
24+
`Zend\Expressive\Exception\InvalidMiddlewareException`.
25+
26+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) adds a new
27+
class, `Zend\Expressive\MiddlewareFactory`. The class composes a
28+
`MiddlewareContainer`, and exposes the following methods:
29+
30+
- `callable(callable $middleware) : CallableMiddlewareDecorator`
31+
- `handler(RequestHandlerInterface $handler) : RequestHandlerMiddleware`
32+
- `lazy(string $service) : LazyLoadingMiddleware`
33+
- `prepare($middleware) : MiddlewareInterface`: accepts a string service name,
34+
callable, `RequestHandlerInterface`, `MiddlewareInterface`, or array of such
35+
values, and returns a `MiddlewareInterface`, raising an exception if it
36+
cannot determine what to do.
37+
- `pipeline(...$middleware) : MiddlewarePipe`: passes each argument to
38+
`prepare()`, and the result to `MiddlewarePipe::pipe()`, returning the
39+
pipeline when complete.
40+
41+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) adds
42+
the following factory classes, each within the `Zend\Expressive\Container`
43+
namespace:
44+
45+
- `ApplicationPipelineFactory`: creates and returns a
46+
`Zend\Stratigility\MiddlewarePipe` to use as the application middleware
47+
pipeline.
48+
- `DispatchMiddlewareFactory`: creates and returns a `Zend\Expressive\Router\DispatchMiddleware` instance.
49+
- `EmitterFactory`: creates and returns a
50+
`Zend\HttpHandlerRunner\Emitter\EmitterStack` instance composing an
51+
`SapiEmitter` from that same namespace as the only emitter on the stack.
52+
This is used as a dependency for the `Zend\HttpHandlerRunner\RequestHandlerRunner`
53+
service.
54+
- `MiddlewareContainerFactory`: creates and returns a `Zend\Expressive\MiddlewareContainer`
55+
instance decorating the PSR-11 container passed to the factory.
56+
- `MiddlewareFactoryFactory`: creates and returns a `Zend\Expressive\MiddlewareFactory`
57+
instance decorating a `MiddlewareContainer` instance as pulled from the
58+
container.
59+
- `RequestHandlerRunnerFactory`: creates and returns a
60+
`Zend\HttpHandlerRunner\RequestHandlerRunner` instance, using the services
61+
`Zend\Expressive\Application`, `Zend\HttpHandlerRunner\Emitter\EmitterInterface`,
62+
`Zend\Expressive\ServerRequestFactory`, and `Zend\Expressive\ServerRequestErrorResponseGenerator`.
63+
- `RouteMiddlewareFactory`: creates and returns a `Zend\Expressive\Router\PathBasedRoutingMiddleware` instance.
64+
- `ServerRequestFactoryFactory`: creates and returns a `callable` factory for
65+
generating a PSR-7 `ServerRequestInterface` instance; this returned factory is a
66+
dependency for the `Zend\HttpHandlerRunner\RequestHandlerRunner` service.
67+
- `ServerRequestErrorResponseGeneratorFactory`: creates and returns a
68+
`callable` that accepts a PHP `Throwable` in order to generate a PSR-7
69+
`ResponseInterface` instance; this returned factory is a dependency for the
70+
`Zend\HttpHandlerRunner\RequestHandlerRunner` service, which uses it to
71+
generate a response in the scenario that the `ServerRequestFactory` is
72+
unable to create a request instance.
73+
74+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) adds
75+
the class `Zend\Expressive\Container\ApplicationConfigInjectionDelegator`.
76+
This class may be used either as a delegator factory on the
77+
`Zend\Expressive\Application` instance, or you may use the two static methods
78+
it defines to inject pipeline middleware and/or routes from configuration:
79+
80+
- `injectPipelineFromConfig(Application $application, array $config) : void`
81+
- `injectRoutesFromConfig(Application $application, array $config) : void`
82+
83+
These methods work the same way as the associated `Application` methods from
84+
version 2, accepting the same configuration.
85+
86+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) adds
87+
`Zend\Expressive\ConfigProvider`, which details the default service mappings.
88+
89+
### Changed
90+
91+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) adds
92+
dependencies on each of:
93+
94+
- zend-stratigility 3.0.0alpha3
95+
- zend-expressive-router 3.0.0alpha1
96+
- zend-httphandlerrunner 1.0.0
97+
98+
and removes the dependency http-interop/http-server-middleware.
99+
100+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) renames
101+
`Zend\Expressive\Middleware\NotFoundHandler` to
102+
`Zend\Expressive\Middleware\NotFoundMiddleware`, and its accompanying factory
103+
`Zend\Expressive\Container\NotFoundHandlerFactory` to
104+
`Zend\Expressive\Container\NotFoundMiddlewareFactory`.
105+
106+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) renames
107+
`Zend\Expressive\Delegate\NotFoundDelegate` to
108+
`Zend\Expressive\Handler\NotFoundHandler`, updating it to implement the PSR-15
109+
`RequestHandlerInterface`. It also renames the factory
110+
`Zend\Expressive\Container\NotFoundDelegateFactory` to
111+
`Zend\Expressive\Container\NotFoundHandlerFactory`.
112+
113+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) refactors
114+
`Zend\Expressive\Application` completely.
115+
116+
The class no longer extends `Zend\Stratigility\MiddlewarePipe`, and instead
117+
implements the PSR-15 `MiddlewareInterface` and `RequestHandlerInterface`.
118+
119+
It now **requires** the following dependencies via constructor injection, in
120+
the following order:
121+
122+
- `Zend\Expressive\MiddlewareFactory`
123+
- `Zend\Stratigility\MiddlewarePipe`; this is the pipeline representing the application.
124+
- `Zend\Expressive\Router\PathBasedRoutingMiddleware`
125+
- `Zend\HttpHandlerRunner\RequestHandlerRunner`
126+
127+
It removes all "getter" methods (as detailed in the "Removed" section of this
128+
release), but retains the following methods, with the changes described below.
129+
Please note: in most cases, these methods accept the same arguments as in the
130+
version 2 series, with the exception of callable double-pass middleware (these
131+
may be decorated manually using `Zend\Stratigility\doublePassMiddleware()`),
132+
and http-interop middleware (no longer supported; rewrite as PSR-15
133+
middleware).
134+
135+
- `pipe($middlewareOrPath, $middleware = null) : void` passes its arguments to
136+
the composed `MiddlewareFactory`'s `prepare()` method; if two arguments are
137+
provided, the second is passed to the factory, and the two together are
138+
passed to `Zend\Stratigility\path()` in order to decorate them to work as
139+
middleware. The prepared middleware is then piped to the composed
140+
`MiddlewarePipe` instance.
141+
142+
As a result of switching to use the `MiddlewareFactory` to prepare
143+
middleware, you may now pipe `RequestHandlerInterface` instances as well.
144+
145+
- `route(string $path, $middleware, array $methods = null, string $name) : Route`
146+
passes its `$middleware` argument to the `MiddlewareFactory::prepare()`
147+
method, and then all arguments to the composed `PathBasedRoutingMiddleware`
148+
instance's `route()` method.
149+
150+
As a result of switching to use the `MiddlewareFactory` to prepare
151+
middleware, you may now route to `RequestHandlerInterface` instances as
152+
well.
153+
154+
- Each of `get`, `post`, `patch`, `put`, `delete`, and `any` now proxy to
155+
`route()` after marshaling the correct `$methods`.
156+
157+
- `getRoutes() : Route[]` proxies to the composed `PathBasedRoutingMiddleware`
158+
instance.
159+
160+
- `handle(ServerRequestInterface $request) : ResponseInterface` proxies to the
161+
composed `MiddlewarePipe` instance's `handle()` method.
162+
163+
- `process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface`
164+
proxies to the composed `MiddlewarePipe` instance's `process()` method.
165+
166+
- `run() : void` proxies to the composed `RequestHandlerRunner` instance.
167+
Please note that the method no longer accepts any arguments.
168+
169+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) modifies the
170+
`Zend\Expressive\Container\ApplicationFactory` to reflect the changes to the
171+
`Zend\Expressive\Application` class as detailed above. It pulls the following
172+
services to inject via the constructor:
173+
174+
- `Zend\Expressive\MiddlewareFactory`
175+
- `Zend\Stratigility\ApplicationPipeline`, which should resolve to a
176+
`MiddlewarePipe` instance; use the
177+
`Zend\Expressive\Container\ApplicationPipelineFactory`.
178+
- `Zend\Expressive\Router\PathBasedRoutingMiddleware`
179+
- `Zend\HttpHandlerRunner\RequestHandlerRunner`
180+
181+
### Deprecated
182+
183+
- Nothing.
184+
185+
### Removed
186+
187+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) removes
188+
support for http-interop/http-server-middleware.
189+
190+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) removes the
191+
class `Zend\Expressive\Middleware\RouteMiddleware`. Use the
192+
`PathBasedRoutingMiddleware` or `RouteMiddleware` from zend-expressive-router
193+
instead; the factory `Zend\Expressive\Container\RouteMiddlewareFactory` will
194+
return a `PathBasedRoutingMiddleware` instance for you.
195+
196+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) removes the
197+
class `Zend\Expressive\Middleware\DispatchMiddleware`. Use the
198+
`DispatchMiddleware` from zend-expressive-router instead; the factory
199+
`Zend\Expressive\Container\DispatchMiddlewareFactory` will return an instance
200+
for you.
201+
202+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) removes the
203+
class `Zend\Expressive\Emitter\EmitterStack`; use the class
204+
`Zend\HttpHandlerRunner\Emitter\EmitterStack` instead.
205+
206+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) removes the
207+
following methods from `Zend\Expressive\Application`:
208+
209+
- `pipeRoutingMiddleware()`: use `pipe(\Zend\Expressive\Router\PathBasedRoutingMiddleware::class)` instead.
210+
- `pipeDispatchMiddleware()`: use `pipe(\Zend\Expressive\Router\DispatchMiddleware::class)` instead.
211+
- `getContainer()`
212+
- `getDefaultDelegate()`: ensure you pipe middleware capable of returning a response at the innermost layer; this can be done by decorating a request handler using `Zend\Stratigility\Middleware\RequestHandlerMiddleware`, using `Zend\Expressive\Middleware\NotFoundMiddleware`, or other approaches.
213+
- `getEmitter()`: use the `Zend\HttpHandlerRunner\Emitter\EmitterInterface` service from the container.
214+
- `injectPipelineFromConfig()`: use the new `ApplicationConfigInjectionDelegator` and/or the static method of the same name it defines.
215+
- `injectRoutesFromConfig()`: use the new `ApplicationConfigInjectionDelegator` and/or the static method of the same name it defines.
216+
217+
- [#543](https://github.com/zendframework/zend-expressive/pull/543) removes the
218+
class `Zend\Expressive\AppFactory`.
219+
220+
### Fixed
221+
222+
- Nothing.
223+
5224
## 3.0.0alpha1 - 2018-01-22
6225

7226
### Added

composer.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@
2424
"require": {
2525
"php": "^7.1",
2626
"fig/http-message-util": "^1.1.2",
27-
"http-interop/http-server-middleware": "^1.0.1",
2827
"psr/container": "^1.0",
2928
"psr/http-message": "^1.0.1",
29+
"psr/http-server-middleware": "^1.0",
3030
"zendframework/zend-diactoros": "^1.3.10",
31-
"zendframework/zend-expressive-router": "^3.0.0-dev",
31+
"zendframework/zend-expressive-router": "^3.0.0alpha1",
3232
"zendframework/zend-expressive-template": "^2.0.0-dev",
33-
"zendframework/zend-stratigility": "^3.0.0alpha1@alpha"
33+
"zendframework/zend-httphandlerrunner": "^1.0",
34+
"zendframework/zend-stratigility": "3.0.0alpha3"
3435
},
3536
"require-dev": {
3637
"filp/whoops": "^1.1.10 || ^2.1.13",
@@ -62,10 +63,7 @@
6263
"autoload-dev": {
6364
"psr-4": {
6465
"ZendTest\\Expressive\\": "test/"
65-
},
66-
"files": [
67-
"test/class_exists.php"
68-
]
66+
}
6967
},
7068
"config": {
7169
"sort-packages": true
@@ -75,6 +73,9 @@
7573
"dev-master": "2.1.x-dev",
7674
"dev-develop": "2.2.x-dev",
7775
"dev-release-3.0.0": "3.0.x-dev"
76+
},
77+
"zf": {
78+
"config-provider": "Zend\\Expressive\\ConfigProvider"
7879
}
7980
},
8081
"bin": [

0 commit comments

Comments
 (0)