Download the PHP package broswilli/laravel-yml-routes without Composer
On this page you can find all versions of the php package broswilli/laravel-yml-routes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download broswilli/laravel-yml-routes
More information about broswilli/laravel-yml-routes
Files in broswilli/laravel-yml-routes
Package laravel-yml-routes
Short Description Create laravels routes by editing simple YAML Files
License MIT
Homepage https://github.com/broswilli/laravel-yml-routes
Informations about the package laravel-yml-routes
Laravel YAML Routes
This package is created for Laravel Developers to create routes using YAML files. This package makes it easy for many routes to be created and arranged with well organized prefixes and middleware.
Installation
You can install the package via composer:
You can publish configuration files
Edit the Root YAML File:
Create a yaml file of choice for the sake of this example create admin.yaml file in the same directory as the root.yaml file
Output routes in the routes.php file
Usage
Edit the root YAML file
From the YAML above the root nodes resource_1 and resource_2 points to other yaml files that describes a group of routes. The root nodes resource_3 and resource_4 creates 2 new routes with url example.com/root-test and example.com/root-invoke.
example.yaml
All urls from example.yaml will have a prefix of front and a common middleware of 'can:isAdmin' applied:
- example.com/front/test
- example.com/front/invoke
The front prefix and the middleware was defined in the root.yaml file
Route Names and Methods
- test_resource
- Route Name(s): test_resource
- Method(s): GET
- Controller Class: Adapt\SchAdmin\Http\Controllers\SampleController
- Action: index
- test_resource_2
- Route Names(s): resc.index, resc.store, resc.create, resc.show, resc.edit, resc.update, resc.destroy
- Methods: GET, POST, PUT, DELETE
- Controller Class: Adapt\SchAdmin\Http\Controllers\ResourceController
- test_resource_3: This is similar to test_resource_2 suitable for restful API's. It comes without routes for the create, and edit actions which are not needed for restfull API's
- test_invokable: A controller that has the __invoke method or a single action controller. You can create the route without stating the action
Please visit https://laravel.com/docs/11.x/controllers#resource-controllers to know more about resource controllers.
Visit https://laravel.com/docs/11.x/controllers#api-resource-routes to know more about API Resource.
Visit https://laravel.com/docs/11.x/controllers#single-action-controllers to know more about single action controllers
Route Prefixes
The example2.yaml is used to demonstrate route prefixes. In the root.yaml file it was referenced as follows:
example2.yaml
The root.yaml file where the example2 routes were defined has a node with a key of name. The function of the name node is to create route name prefix.
- admin-index
- Route Name(s): admin.admin-index
- Method(s): GET
- Controller Class: Adapt\SchAdmin\Http\Controllers\AdminController
- Action: index
Notice that the Route Name is admin.admin-index instead of admin-index because of the name node defined in the root.yaml file
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Weli Orlu
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.