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

Commit e943760

Browse files
committed
Merge branch 'hotfix/486'
Close #486
2 parents 995c4b0 + 758c142 commit e943760

File tree

9 files changed

+130
-130
lines changed

9 files changed

+130
-130
lines changed

doc/book/cookbook/custom-404-page-handling.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
> This recipe is deprecated with the release of Expressive 2.0, as that release
66
> now expects and requires that you provide innermost middleware that will
77
> return a response, and provides `Zend\Expressive\Middleware\NotFoundHandler`
8-
> as a default implementation. Please see the [error handling chapter](../error-handling.md#page-not-found)
8+
> as a default implementation. Please see the [error handling chapter](../features/error-handling.md)
99
> for more information.
1010
1111
In some cases, you may want to handle 404 errors separately from the
@@ -28,7 +28,7 @@ Your 404 handler can take one of two approaches:
2828
In the first approach, the `NotFound` middleware can be as simple as this:
2929

3030
```php
31-
namespace Application;
31+
namespace App;
3232

3333
class NotFound
3434
{
@@ -56,7 +56,7 @@ In our example here, we will render a specific template, and use this to seed
5656
and return a response.
5757

5858
```php
59-
namespace Application;
59+
namespace App;
6060

6161
use Zend\Expressive\Template\TemplateRendererInterface;
6262

@@ -85,7 +85,7 @@ that does not rely on the final handler.
8585

8686
## Registering custom 404 handlers
8787

88-
We can register either `Application\NotFound` class above as service in the
88+
We can register either `App\NotFound` class above as service in the
8989
[service container](../features/container/intro.md). In the case of the second approach,
9090
you would also need to provide a factory for creating the middleware (to ensure
9191
you inject the template renderer).
@@ -109,7 +109,7 @@ configuration, after the dispatch middleware:
109109
'priority' => 1,
110110
],
111111
[
112-
'middleware' => 'Application\NotFound',
112+
'middleware' => 'App\NotFound',
113113
'priority' => -1,
114114
],
115115
/* ... */
@@ -123,7 +123,7 @@ To manually add the middleware, you will need to pipe it to the application
123123
instance:
124124

125125
```php
126-
$app->pipe($container->get('Application\NotFound'));
126+
$app->pipe($container->get('App\NotFound'));
127127
```
128128

129129
This must be done *after*:

doc/book/features/container/aura-di.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $ composer require aura/di
2525
Aura.Di can help you to organize your code better with
2626
[ContainerConfig classes](http://auraphp.com/packages/Aura.Di/config.html) and
2727
[two step configuration](http://auraphp.com/blog/2014/04/07/two-stage-config/).
28-
In this example, we'll put that in `config/services.php`:
28+
In this example, we'll put that in `config/container.php`:
2929

3030
```php
3131
<?php
@@ -129,7 +129,7 @@ Your bootstrap (typically `public/index.php`) will then look like this:
129129
```php
130130
chdir(dirname(__DIR__));
131131
require 'vendor/autoload.php';
132-
$container = require 'config/services.php';
132+
$container = require 'config/container.php';
133133
$app = $container->get(Zend\Expressive\Application::class);
134134
require 'config/pipeline.php';
135135
require 'config/routes.php';

doc/book/features/container/pimple.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $ composer require xtreamwayz/pimple-container-interop
2626

2727
To configure Pimple, instantiate it, and then add the factories desired. We
2828
recommend doing this in a dedicated script that returns the Pimple instance; in
29-
this example, we'll have that in `config/services.php`.
29+
this example, we'll have that in `config/container.php`.
3030

3131
```php
3232
use Xtreamwayz\Pimple\Container as Pimple;
@@ -51,10 +51,10 @@ $container['Zend\Expressive\Router\RouterInterface'] = function ($container) {
5151
// Expressive 2.X: We'll provide a default delegate:
5252
$delegateFactory = new Container\NotFoundDelegateFactory();
5353
$container['Zend\Expressive\Delegate\DefaultDelegate'] = $delegateFactory;
54-
$container['Zend\Expressive\Delegate\NotFoundDelegate'] = $delegateFactory;
54+
$container[Zend\Expressive\Delegate\NotFoundDelegate::class] = $delegateFactory;
5555

5656
// Expressive 2.X: We'll provide a not found handler:
57-
$container['Zend\Expressive\Middleware\NotFoundHandler'] = new Container\NotFoundHandlerFactory();
57+
$container[Zend\Expressive\Middleware\NotFoundHandler::class] = new Container\NotFoundHandlerFactory();
5858

5959
// Templating
6060
// In most cases, you can instantiate the template renderer you want to use
@@ -80,13 +80,13 @@ $container['Zend\Expressive\Middleware\ErrorHandler'] = new Container\ErrorHandl
8080
// - Expressive 1.X:
8181
$container['Zend\Expressive\FinalHandler'] = new Container\WhoopsErrorHandlerFactory();
8282
// - Expressive 2.X:
83-
$container['Zend\Expressive\Middleware\ErrorResponseGenerator'] = new Container\WhoopsErrorResponseGeneratorFactory();
83+
$container[Zend\Expressive\Middleware\ErrorResponseGenerator::class] = new Container\WhoopsErrorResponseGeneratorFactory();
8484

8585
// If in production:
8686
// - Expressive 1.X:
8787
$container['Zend\Expressive\FinalHandler'] = new Container\TemplatedErrorHandlerFactory();
8888
// - Expressive 2.X:
89-
$container['Zend\Expressive\Middleware\ErrorResponseGenerator'] = new Container\ErrorResponseGeneratorFactory();
89+
$container[Zend\Expressive\Middleware\ErrorResponseGenerator::class] = new Container\ErrorResponseGeneratorFactory();
9090

9191
return $container;
9292
```
@@ -95,8 +95,8 @@ Your bootstrap (typically `public/index.php`) will then look like this:
9595

9696
```php
9797
chdir(dirname(__DIR__));
98-
$container = require 'config/services.php';
99-
$app = $container->get('Zend\Expressive\Application');
98+
$container = require 'config/container.php';
99+
$app = $container->get(Zend\Expressive\Application::class);
100100

101101
// In Expressive 2.X:
102102
require 'config/pipeline.php';

doc/book/features/container/zend-servicemanager.md

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ For this example, we'll assume your application configuration (used by several
7171
factories to configure instances) is in `config/config.php`, and that that file
7272
returns an array.
7373

74-
We'll create a `config/services.php` file that creates and returns a
74+
We'll create a `config/container.php` file that creates and returns a
7575
`Zend\ServiceManager\ServiceManager` instance as follows:
7676

7777
```php
@@ -82,24 +82,24 @@ $container = new ServiceManager();
8282
// Application and configuration
8383
$container->setService('config', include 'config/config.php');
8484
$container->setFactory(
85-
'Zend\Expressive\Application',
86-
'Zend\Expressive\Container\ApplicationFactory'
85+
Zend\Expressive\Application::class,
86+
Zend\Expressive\Container\ApplicationFactory::class
8787
);
8888

8989
// Routing
9090
// In most cases, you can instantiate the router you want to use without using a
9191
// factory:
9292
$container->setInvokableClass(
93-
'Zend\Expressive\Router\RouterInterface',
94-
'Zend\Expressive\Router\AuraRouter'
93+
Zend\Expressive\Router\RouterInterface::class,
94+
Zend\Expressive\Router\AuraRouter::class
9595
);
9696

9797
// Templating
9898
// In most cases, you can instantiate the template renderer you want to use
9999
// without using a factory:
100100
$container->setInvokableClass(
101-
'Zend\Expressive\Template\TemplateRendererInterface',
102-
'Zend\Expressive\Plates\PlatesRenderer'
101+
Zend\Expressive\Template\TemplateRendererInterface::class,
102+
Zend\Expressive\Plates\PlatesRenderer::class
103103
);
104104

105105
// These next two can be added in any environment; they won't be used unless
@@ -108,43 +108,43 @@ $container->setInvokableClass(
108108
// ErrorResponseGenerator implementation (Expressive 2.X):
109109
$container->setFactory(
110110
'Zend\Expressive\Whoops',
111-
'Zend\Expressive\Container\WhoopsFactory'
111+
Zend\Expressive\Container\WhoopsFactory::class
112112
);
113113
$container->setFactory(
114114
'Zend\Expressive\WhoopsPageHandler',
115-
'Zend\Expressive\Container\WhoopsPageHandlerFactory'
115+
Zend\Expressive\Container\WhoopsPageHandlerFactory::class
116116
);
117117

118118
// Error Handling
119119

120120
// - Expressive 2.X, all environments:
121121
$container->setFactory(
122-
'Zend\Expressive\Middleware\ErrorHandler',
123-
'Zend\Expressive\Container\ErrorHandlerFactory'
122+
Zend\Expressive\Middleware\ErrorHandler::class,
123+
Zend\Expressive\Container\ErrorHandlerFactory::class
124124
);
125125

126126
// If in development:
127127
// - Expressive 1.X:
128128
$container->setFactory(
129129
'Zend\Expressive\FinalHandler',
130-
'Zend\Expressive\Container\WhoopsErrorHandlerFactory'
130+
Zend\Expressive\Container\WhoopsErrorHandlerFactory::class
131131
);
132132
// - Expressive 2.X:
133133
$container->setFactory(
134-
'Zend\Expressive\Middleware\ErrorResponseGenerator',
135-
'Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory'
134+
Zend\Expressive\Middleware\ErrorResponseGenerator::class,
135+
Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory::class
136136
);
137137

138138
// If in production:
139139
// - Expressive 1.X:
140140
$container->setFactory(
141141
'Zend\Expressive\FinalHandler',
142-
'Zend\Expressive\Container\TemplatedErrorHandlerFactory'
142+
Zend\Expressive\Container\TemplatedErrorHandlerFactory::class
143143
);
144144
// - Expressive 2.X:
145145
$container->setFactory(
146-
'Zend\Expressive\Middleware\ErrorResponseGenerator',
147-
'Zend\Expressive\Container\ErrorResponseGeneratorFactory'
146+
Zend\Expressive\Middleware\ErrorResponseGenerator::class,
147+
Zend\Expressive\Container\ErrorResponseGeneratorFactory::class
148148
);
149149

150150
return $container;
@@ -155,8 +155,8 @@ Your bootstrap (typically `public/index.php`) will then look like this:
155155
```php
156156
chdir(dirname(__DIR__));
157157
require 'vendor/autoload.php';
158-
$container = require 'config/services.php';
159-
$app = $container->get('Zend\Expressive\Application');
158+
$container = require 'config/container.php';
159+
$app = $container->get(\Zend\Expressive\Application::class);
160160

161161
// Expressive 2.X:
162162
require 'config/pipeline.php';
@@ -170,7 +170,7 @@ $app->run();
170170

171171
Alternately, you can use a configuration file to define the container. As
172172
before, we'll define our configuration in `config/config.php`, and our
173-
`config/services.php` file will still return our service manager instance; we'll
173+
`config/container.php` file will still return our service manager instance; we'll
174174
define the service configuration in `config/dependencies.php`:
175175

176176
```php
@@ -183,23 +183,23 @@ return [
183183
'Zend\Expressive\Delegate\DefaultDelegate' => 'Zend\Expressive\Delegate\NotFoundDelegate',
184184
],
185185
'invokables' => [
186-
'Zend\Expressive\Router\RouterInterface' => 'Zend\Expressive\Router\AuraRouter',
187-
'Zend\Expressive\Template\TemplateRendererInterface' => 'Zend\Expressive\Plates\PlatesRenderer'
186+
Zend\Expressive\Router\RouterInterface::class => Zend\Expressive\Router\AuraRouter::class,
187+
Zend\Expressive\Template\TemplateRendererInterface::class => 'Zend\Expressive\Plates\PlatesRenderer::class
188188
],
189189
'factories' => [
190-
'Zend\Expressive\Application' => 'Zend\Expressive\Container\ApplicationFactory',
191-
'Zend\Expressive\Whoops' => 'Zend\Expressive\Container\WhoopsFactory',
192-
'Zend\Expressive\WhoopsPageHandler' => 'Zend\Expressive\Container\WhoopsPageHandlerFactory',
190+
Zend\Expressive\Application::class => Zend\Expressive\Container\ApplicationFactory::class,
191+
'Zend\Expressive\Whoops' => Zend\Expressive\Container\WhoopsFactory::class,
192+
'Zend\Expressive\WhoopsPageHandler' => Zend\Expressive\Container\WhoopsPageHandlerFactory::class,
193193

194194
// Expressive 2.0:
195-
'Zend\Expressive\Middleware\ErrorHandler' => 'Zend\Expressive\Container\ErrorHandlerFactory',
196-
'Zend\Expressive\Delegate\NotFoundDelegate' => 'Zend\Expressive\Container\NotFoundDelegateFactory',
197-
'Zend\Expressive\Middleware\NotFoundHandler' => 'Zend\Expressive\Container\NotFoundHandlerFactory',
195+
Zend\Stratigility\Middleware\ErrorHandler::class => Zend\Expressive\Container\ErrorHandlerFactory::class,
196+
Zend\Expressive\Delegate\NotFoundDelegate::class => Zend\Expressive\Container\NotFoundDelegateFactory::class,
197+
Zend\Expressive\Middleware\NotFoundHandler::class => Zend\Expressive\Container\NotFoundHandlerFactory::class,
198198
],
199199
];
200200
```
201201

202-
`config/services.php` becomes:
202+
`config/container.php` becomes:
203203

204204
```php
205205
use Zend\ServiceManager\Config;
@@ -216,40 +216,40 @@ You have two choices on how to approach this:
216216
- Define the final handler service in an environment specific file and use file
217217
globbing to merge files.
218218

219-
In the first case, you would change the `config/services.php` example to look
219+
In the first case, you would change the `config/container.php` example to look
220220
like this:
221221

222222
```php
223223
use Zend\ServiceManager\Config;
224224
use Zend\ServiceManager\ServiceManager;
225225

226-
$container = new ServiceManager(new Config(include 'config/services.php'));
226+
$container = new ServiceManager(new Config(include 'config/container.php'));
227227
switch ($variableOrConstantIndicatingEnvironment) {
228228
case 'development':
229229
// Expressive 1.X:
230230
$container->setFactory(
231231
'Zend\Expressive\FinalHandler',
232-
'Zend\Expressive\Container\WhoopsErrorHandlerFactory'
232+
Zend\Expressive\Container\WhoopsErrorHandlerFactory::class
233233
);
234234

235235
// Expressive 2.X:
236236
$container->setFactory(
237-
'Zend\Expressive\Middleware\ErrorResponseGenerator',
238-
'Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory'
237+
Zend\Expressive\Middleware\ErrorResponseGenerator::class,
238+
Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory::class
239239
);
240240
break;
241241
case 'production':
242242
default:
243243
// Expressive 1.X:
244244
$container->setFactory(
245245
'Zend\Expressive\FinalHandler',
246-
'Zend\Expressive\Container\TemplatedErrorHandlerFactory'
246+
Zend\Expressive\Container\TemplatedErrorHandlerFactory::class
247247
);
248248

249249
// Expressive 2.X:
250250
$container->setFactory(
251-
'Zend\Expressive\Middleware\ErrorResponseGenerator',
252-
'Zend\Expressive\Container\ErrorResponseGeneratorFactory'
251+
Zend\Expressive\Middleware\ErrorResponseGenerator::class,
252+
Zend\Expressive\Container\ErrorResponseGeneratorFactory::class
253253
);
254254
}
255255
return $container;
@@ -285,25 +285,25 @@ return [
285285
],
286286
'aliases' => [
287287
// Expressive 2.0:
288-
'Zend\Expressive\Delegate\DefaultDelegate' => 'Zend\Expressive\Delegate\NotFoundDelegate',
288+
'Zend\Expressive\Delegate\DefaultDelegate' => Zend\Expressive\Delegate\NotFoundDelegate::class,
289289
],
290290
'invokables' => [
291-
'Zend\Expressive\Router\RouterInterface' => 'Zend\Expressive\Router\AuraRouter',
292-
'Zend\Expressive\Template\TemplateRendererInterface' => 'Zend\Expressive\Plates\PlatesRenderer'
291+
Zend\Expressive\Router\RouterInterface::class => Zend\Expressive\Router\AuraRouter::class,
292+
Zend\Expressive\Template\TemplateRendererInterface::class => 'Zend\Expressive\Plates\PlatesRenderer::class
293293
],
294294
'factories' => [
295-
'Zend\Expressive\Application' => 'Zend\Expressive\Container\ApplicationFactory',
296-
'Zend\Expressive\Whoops' => 'Zend\Expressive\Container\WhoopsFactory',
297-
'Zend\Expressive\WhoopsPageHandler' => 'Zend\Expressive\Container\WhoopsPageHandlerFactory',
295+
Zend\Expressive\Application::class => Zend\Expressive\Container\ApplicationFactory::class,
296+
'Zend\Expressive\Whoops' => Zend\Expressive\Container\WhoopsFactory::class,
297+
'Zend\Expressive\WhoopsPageHandler' => Zend\Expressive\Container\WhoopsPageHandlerFactory::class,
298298

299299
// Expressive 1.X:
300-
'Zend\Expressive\FinalHandler' => 'Zend\Expressive\Container\TemplatedErrorHandlerFactory',
300+
'Zend\Expressive\FinalHandler' => Zend\Expressive\Container\TemplatedErrorHandlerFactory::class,
301301

302302
// Expressive 2.X:
303-
'Zend\Expressive\Middleware\ErrorResponseGenerator' => 'Zend\Expressive\Container\ErrorResponseGeneratorFactory',
304-
'Zend\Expressive\Middleware\ErrorHandler' => 'Zend\Expressive\Container\ErrorHandlerFactory',
305-
'Zend\Expressive\Delegate\NotFoundDelegate' => 'Zend\Expressive\Container\NotFoundDelegateFactory',
306-
'Zend\Expressive\Middleware\NotFoundHandler' => 'Zend\Expressive\Container\NotFoundHandlerFactory',
303+
Zend\Expressive\Middleware\ErrorResponseGenerator::class => Zend\Expressive\Container\ErrorResponseGeneratorFactory::class,
304+
Zend\Stratigility\Middleware\ErrorHandler::class => Zend\Expressive\Container\ErrorHandlerFactory::class,
305+
'Zend\Expressive\Delegate\NotFoundDelegate' => Zend\Expressive\Container\NotFoundDelegateFactory::class,
306+
Zend\Expressive\Middleware\NotFoundHandler::class => Zend\Expressive\Container\NotFoundHandlerFactory::class,
307307
],
308308
];
309309
```
@@ -314,14 +314,14 @@ like this:
314314
```php
315315
return [
316316
'factories' => [
317-
'Zend\Expressive\Whoops' => 'Zend\Expressive\Container\WhoopsFactory',
318-
'Zend\Expressive\WhoopsPageHandler' => 'Zend\Expressive\Container\WhoopsPageHandlerFactory',
317+
'Zend\Expressive\Whoops' => Zend\Expressive\Container\WhoopsFactory::class,
318+
'Zend\Expressive\WhoopsPageHandler' => Zend\Expressive\Container\WhoopsPageHandlerFactory::class,
319319

320320
// Expressive 1.X:
321-
'Zend\Expressive\FinalHandler' => 'Zend\Expressive\Container\WhoopsErrorHandlerFactory',
321+
'Zend\Expressive\FinalHandler' => Zend\Expressive\Container\WhoopsErrorHandlerFactory::class,
322322

323323
// Expressive 2.X:
324-
'Zend\Expressive\Middleware\ErrorResponseGenerator' => 'Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory',
324+
Zend\Expressive\Middleware\ErrorResponseGenerator::class => 'Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory::class,
325325
],
326326
];
327327
```

0 commit comments

Comments
 (0)