Skip to content

Commit 7fac1dc

Browse files
committed
Update readme
1 parent a6f6494 commit 7fac1dc

File tree

1 file changed

+22
-29
lines changed

1 file changed

+22
-29
lines changed

README.md

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -118,35 +118,7 @@ it into a nice JSON response.
118118

119119
#### Slim 4 integration
120120

121-
```php
122-
<?php
123-
124-
use Selective\Validation\Encoder\JsonEncoder;
125-
use Selective\Validation\Middleware\ValidationExceptionMiddleware;
126-
use Selective\Validation\Transformer\ErrorDetailsResultTransformer;
127-
use Slim\Factory\AppFactory;
128-
129-
require_once __DIR__ . '/../vendor/autoload.php';
130-
131-
$app = AppFactory::create();
132-
133-
$app->add(new ValidationExceptionMiddleware(
134-
$app->getResponseFactory(),
135-
new ErrorDetailsResultTransformer(),
136-
new JsonEncoder()
137-
));
138-
139-
// If you are using a container, you can also use this option:
140-
// $app->add(ValidationExceptionMiddleware::class);
141-
142-
// ...
143-
144-
$app->run();
145-
```
146-
147-
### Container definition
148-
149-
This example uses PHI-DI:
121+
Insert a container definition for `ValidationExceptionMiddleware::class`:
150122

151123
```php
152124
<?php
@@ -188,6 +160,27 @@ return [
188160
];
189161
```
190162

163+
Add the `ValidationExceptionMiddleware` into your middlware stack:
164+
165+
```php
166+
<?php
167+
168+
use Selective\Validation\Middleware\ValidationExceptionMiddleware;
169+
use Slim\Factory\AppFactory;
170+
171+
require_once __DIR__ . '/../vendor/autoload.php';
172+
173+
$app = AppFactory::create();
174+
175+
// ...
176+
177+
$app->add(ValidationExceptionMiddleware::class);
178+
179+
// ...
180+
181+
$app->run();
182+
```
183+
191184
#### Usage
192185

193186
```php

0 commit comments

Comments
 (0)