A Laravel package to auto-generate routes from static blade view.
You can use this package to generated simple page that does not require processing in a controller.
If you like this package you can Buy me a Coffee ☕️
You can install the package via composer:
composer require jornatf/laravel-route-generator
You can publish the config file with:
php artisan vendor:publish --tag="laravel-route-generator-config"
This is the contents of the published config file:
return [
/*
|--------------------------------------------------------------------------
| View base path
|--------------------------------------------------------------------------
|
| Specify here the folder containing the blade views for the routes. This
| base will not be in the URL.
|
*/
'view_base_path' => 'static',
/*
|--------------------------------------------------------------------------
| URL prefix
|--------------------------------------------------------------------------
|
| Here you can specify a URL prefix. By default the value is null.
|
*/
'url_prefix' => null,
/*
|--------------------------------------------------------------------------
| Midlewares
|--------------------------------------------------------------------------
|
| You can specify the middlewares that should be used for all automatically
| generated URLs.
|
*/
'middlewares' => [],
];
To start and depending on the configurations, you must create in resources\views
, the folder with the same name as the value of view_base_path
(default: static
).
Then you'll have:
resources/
├─ views/
│ ├─ static/
│ │ ├─ about.blade.php
│ │ ├─ contact.blade.php
Here the routes will be generated:
Method | URL | Route name |
---|---|---|
GET | /about | static.about |
GET | /contact | static.contact |
You can then check the generation of the routes with the Artisan command:
php artisan generated-route:list
You can add prefix to your route group in the config file, like this:
'url_prefix' => 'my_prefix',
You can add middlewares to your route group in the config file, like this:
'middlewares' => ['auth:sanctum'],
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.