Update 05-router.md

This commit is contained in:
Patrick Louys 2016-11-01 16:18:02 +01:00 committed by GitHub
parent 4169afd542
commit b2d2fee013

View file

@ -12,7 +12,7 @@ Alternative packages: [symfony/Routing](https://github.com/symfony/Routing), [Au
By now you know how to install Composer packages, so I will leave that to you.
Now add this code block to your `Bootstrap.php` file where you added the 'hello world' message in the last part.
Now add this code block to your `Bootstrap.php` file where you added the 'hello world' message in the last chapter.
```php
$dispatcher = \FastRoute\simpleDispatcher(function (\FastRoute\RouteCollector $r) {
@ -49,7 +49,7 @@ This setup might work for really small applications, but once you start adding a
Create a `Routes.php` file in the `src/` folder. It should look like this:
```php
<?php
<?php declare(strict_types = 1);
return [
['GET', '/hello-world', function () {
@ -61,7 +61,7 @@ return [
];
```
Now let's rewrite the route collection part to use the `Routes.php` file.
Now let's rewrite the route dispatcher part to use the `Routes.php` file.
```php
$routeDefinitionCallback = function (\FastRoute\RouteCollector $r) {
@ -76,4 +76,6 @@ $dispatcher = \FastRoute\simpleDispatcher($routeDefinitionCallback);
This is already an improvement, but now all the handler code is in the `Routes.php` file. This is not optimal, so let's fix that in the next part.
Don't forget to commit your changes at the end of each chapter.
[<< previous](04-http.md) | [next >>](06-dispatching-to-a-class.md)