jornatf / laravel-route-generator
Laravel package to auto-generate routes from static blade view.
Requires
- php: ^8.0.2
- spatie/laravel-package-tools: ^1.14.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.8
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.8
- pestphp/pest: ^2.20
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-11-08 10:51:54 UTC
README
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 ☕️
Installation
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' => [], ];
Usage
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:
You can then check the generation of the routes with the Artisan command:
php artisan generated-route:list
Prefix
You can add prefix to your route group in the config file, like this:
'url_prefix' => 'my_prefix',
Middlewares
You can add middlewares to your route group in the config file, like this:
'middlewares' => ['auth:sanctum'],
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.