docs: update Route Groups example in README
This commit is contained in:
parent
02dc9387ac
commit
eabe1af518
|
|
@ -65,8 +65,12 @@ $router->group(['prefix' => '/api', 'middleware' => ['auth']])->group(function($
|
||||||
$group->get('/settings', 'SettingsHandler');
|
$group->get('/settings', 'SettingsHandler');
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
All group routes inherit whatever options you pass in (middleware, prefix, etc).
|
||||||
|
|
||||||
|
While the above syntax works and is completely viable, I find the double group method syntax a bit confusing.
|
||||||
|
|
||||||
|
So, here is another way you can do it (my personal preferred method) that is, in my opinion, cleaner, and more readable.
|
||||||
|
|
||||||
You can also save a route group to a variable for more flexible route definitions:
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$api = $router->group(['prefix' => '/api']);
|
$api = $router->group(['prefix' => '/api']);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue