Skip to content

Commit

Permalink
do not discover any controllers by default
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jan 20, 2022
1 parent 96fdfb6 commit c1c787d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/route-discovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* these directories.
*/
'discover_controllers_in_directory' => [
app_path('Http/Controllers'),
// app_path('Http/Controllers'),
],

/*
Expand Down
11 changes: 8 additions & 3 deletions docs/discovering-routes-for-controllers/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ This package can automatically discover and register routes for a directory cont

## Via the config file

First, you need to publish the config file. This will create a file at `config/route-discovery.php`

```bash
php artisan vendor:publish --tag="route-discovery-config"
```

In the `discover_controllers_in_directory` key of the `route-discovery` config file, you can specify a directory that contains controllers.

By default, all controllers in the `app_path('Http/Controllers')` will be registered.
Here you can uncomment the line to register controllers in the `app_path('Http/Controllers')` directory. Of course you can use any directory you want.

```php
// config/route-discovery
Expand All @@ -21,13 +27,12 @@ By default, all controllers in the `app_path('Http/Controllers')` will be regist
'discover_controllers_in_directory' => [
app_path('Http/Controllers'),
],

// ...
```

## Via the routes file

You can also enable route discovery via the routes file. If you want to go this... route 🥁, first remove all entries in the `discover_controllers_in_directory` key of the `route-discovery` config file.
You can also enable route discovery via the routes file.

```php
// in a routes file
Expand Down
2 changes: 1 addition & 1 deletion docs/installation-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ return [
* these directories.
*/
'discover_controllers_in_directory' => [
app_path('Http/Controllers'),
// app_path('Http/Controllers'),
],

/*
Expand Down

0 comments on commit c1c787d

Please sign in to comment.