PHP code example of antoninmasek / laravel-route-directory-macro
1. Go to this page and download the library: Download antoninmasek/laravel-route-directory-macro library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
antoninmasek / laravel-route-directory-macro example snippets
Route::loadFromDirectory(
path: 'routes/app',
middleware: ['web', 'auth'],
);
Route::loadFromDirectory(
path: 'routes/public',
middleware: ['web'],
);
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
then: function () {
Route::loadFromDirectory(
'routes/app',
['web', 'auth'],
);
},
)
public function boot(): void
{
$this->configureRateLimiting();
$this->routes(function () {
Route::loadFromDirectory(
'routes/app',
['web', 'auth'],
);
});
}
Route::loadFromDirectory(
path: 'routes/admin',
middleware: ['web', 'auth', 'admin'],
prefix: 'admin',
);
return [
/*
* List of environments in which hidden routes (route files with `.` prefix) should be registered.
*
* This is useful for working on new routes in certain environments (usually local), while
* ensuring they are not registered in any other environment (usually production).
*/
'register_hidden_routes_in_environments' => [],
];
routes/
│
├── app/
│ ├── users.php
│ ├── tasks.php
│ └── media.php
│
└── public/
└── auth.php