Download the PHP package tanthammar/livewire-auto-routes without Composer
On this page you can find all versions of the php package tanthammar/livewire-auto-routes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tanthammar/livewire-auto-routes
More information about tanthammar/livewire-auto-routes
Files in tanthammar/livewire-auto-routes
Package livewire-auto-routes
Short Description Auto generate routes for Laravel Livewire Components.
License MIT
Informations about the package livewire-auto-routes
livewire-auto-routes
Auto generate routes for Laravel Livewire Components.
Requirements
- Livewire 2
- Laravel 8
- php 8
Use Spatie pkg
I recommend that you try Spatie Laravel Route Attributes before installing this package.
Installation
Routes in web.php
takes precedence!
You can use web.php as normal. Routes declared in your Livewire components are registered after the routes in web.php.
Usage
- You generate routes via traits or by adding a
route()
method to your Livewire component. - Your Livewire components can exist in any folder inside the
app
namespace. - If you don't add any of the traits or the
route()
method, the Livewire component is treated just as a normal component, thus ignored by this package.
Guest route Trait
- Applies the
guest
middleware. - The property is used to generate both the route name and url.
Auth route Trait
- Applies the
auth
middleware. - The property is used to generate both the route name and url.
Custom routes
Option 1
Declare the route just like you would in web.php
Option 2, use the RouteMaker
The RouteMaker can auto-generate the route name from the route definition, but it's optional.
Routes are registered in alphabetical order!
Livewire component FILES are looped in alphabetical order in the app namespace
.
One way to control the load order is to group your components in subfolders with suitable names
like routeGroupA
, routeGroupB
, where routes in "routeGroupA" would be registered before "routeGroupB".
Example using the Traits
It's recommended to keep a controlled naming structure to avoid route conflicts. Use the RouteMaker
if you want better naming.
Directory(asc) = load order | $authRoute or $guestRoute | Generated route name |
---|---|---|
App/Foo/Users/Create.php | users/create | users.create |
App/Foo/Users/CustomStuff.php | users/custom-stuff/{id} | users.custom-stuff.id |
App/Foo/Users/Delete.php | users/delete/{id} | users.delete.id |
App/Foo/Users/Edit.php | users/edit/{id} | users.edit.id |
App/Foo/Users/Index.php | users | users |
App/Foo/Users/Show.php | users/{id} | users.id |
💬 Let's connect
Discuss with other tall-form users on the official Livewire Discord channel. You'll find me in the "partners/tall-forms" channel.
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 open an issue.
License
The MIT License (MIT). Please see License File for more information.