Skip to content

Commit

Permalink
Update docs for slimphp/Slim#3069
Browse files Browse the repository at this point in the history
  • Loading branch information
ddrv committed Apr 18, 2021
1 parent 5000716 commit 8bf3159
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/v4/objects/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ Alternatively, you can take advantage of PHP's `::class` operator which works we
$app->get('/', \HomeController::class . ':home');
```

You can also pass an array, the first element of which will contain the name of the class, and the second will contain the name of the method being called:
```php
$app->get('/', [\HomeController::class, 'home']);
```

In this code above we are defining a `/` route and telling Slim to execute the `home()` method on the `HomeController` class.

Slim first looks for an entry of `HomeController` in the container, if it's found it will use that instance otherwise it will call it's constructor with the container as the first argument. Once an instance of the class is created it will then call the specified method using whatever Strategy you have defined.
Expand Down

0 comments on commit 8bf3159

Please sign in to comment.