Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Livewire Auto Routes Laravel Package

tanthammar/livewire-auto-routes

Livewire Auto Routes automatically registers routes for your Livewire components using convention-based discovery, eliminating repetitive route definitions. Simple setup, customizable patterns, works seamlessly with Laravel and Livewire.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the package:
    composer require tanthammar/livewire-auto-routes
    
  2. Publish its config (typical command, verify against the repo README):
    php artisan vendor:publish --provider="Tanthammar\LivewireAutoRoutes\LivewireAutoRoutesServiceProvider" --tag=config
    
  3. Inspect config/livewire-auto-routes.php. This is the first file to read — it defines the component directory/namespace that gets scanned, the URL prefix, and any middleware/route-group settings the package applies.
  4. Create a component in the scanned folder, e.g. app/Http/Livewire/UserProfile.php. With the package's default conventions you should get a working route at /user-profile without touching routes/web.php.

First use case: replacing a pile of boilerplate Route::get('/foo', Foo::class) entries with a component that "just works" by living in the right directory with the right class name. Verify with php artisan route:list --path=user-profile.

Implementation Patterns

  • Convention-driven full-page components. This package is for static-path, full-page Livewire components. Let the filesystem and class name own the URL (app/Http/Livewire/Admin/Reports/Index.php → /admin/reports/index under the default mapping). Keep the directory clean; anything you don't want routed should live outside the scanned path.
  • Override for the exceptions. Keep auto-routes on for the boring CRUD/settings pages, but register explicit routes manually for anything that needs parameters (/users/{user}), custom names, or domain constraints. There's no reliable way to express dynamic segments through a filename — don't fight it.
  • Middleware via config, auth via groups. Set auth/verified middleware once in the package config; for finer-grained rules, wrap the auto-registered routes in a Route::middleware([...])->group(...) inside your RouteServiceProvider if the package exposes a registration hook, or register the package routes inside your existing groups.
  • Route caching. Ensure the package registers routes during boot() so php artisan route:cache captures them. Add route:clear to your deploy script if you add/remove components.
  • Testing. Snapshot the routes: a small feature test that hits the generated URLs for critical pages catches accidental URL changes when you rename or move a component.
  • Mixed approach. Treat this as a convenience layer for leaf pages, not a replacement for explicit routing. Real applications usually end up with auto-routes for static pages and manual routes for anything resourceful.

Gotchas and Tips

  • It's from 2021 and effectively unmaintened (17 stars, 0 dependents, last release 2021-05-18). The default component namespace it assumes (app/Http/Livewire) is Livewire 2 era; Livewire 3 moved to app/Livewire and changed layout/rendering behavior. Expect to update the config namespace and test carefully, or fork the package.
  • Silent URL changes. Renaming a component class or moving it between folders changes the URL with no redirect. If URLs are public, add tests or a redirect map.
  • Name → slug conversion surprises. Acronyms and numbers can convert unexpectedly (SSOLogin, APIv2Settings). Rename the class if the URL matters.
  • Route conflicts. Manually defined routes and auto-generated ones can collide silently; the one registered first wins. Use php artisan route:list and route:list --path=... to inspect ordering, and remove components from the scanned directory if you need a manual route to win.
  • Caching staleness. route:cache on a build that adds components later means the new URL 404s until you recache. Put route:clear && route:cache in deploy.
  • Debugging order of operations: check the config values (config('livewire-auto-routes.*')), confirm the component file is in the scanned path, confirm the namespace in the config matches the actual PHP namespace, then check route:list.
  • Low-risk alternative. The core idea is a ~30-line loop in RouteServiceProvider::boot() over File::allFiles(app_path('Livewire')) building route strings from relative paths. If the package is unmaintained and you only need this behavior, a small in-house helper is often the better trade.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core