lesichkovm/laravel-advanced-route
An advanced route class for Laravel that extends the framework's default router, letting you register routes with multiple HTTP methods, domains, HTTPS constraints, middleware, and names in one fluent call. Keeps complex route definitions cleaner and easier to maintain.
The package is a thin layer on top of Laravel's router that lets you collapse a block of repetitive controller routes into a single declaration and dispatch to controller methods by convention. It is small enough to read end-to-end before you commit, which is exactly what I'd do first.
Install
composer require lesichkovm/laravel-advanced-route
On Laravel 5.5+ package discovery picks up the service provider automatically. On older versions register it manually in config/app.php (provider + AdvancedRoute alias) — check the extra.laravel block in the package's composer.json for the exact class names, and the autoload.psr-4 block for the namespace root.
Where to look first, in this order
composer.json — the illuminate/support constraint tells you immediately whether it works on your Laravel version. This is the single most important line in the repo.src/ — the provider plus one registrar class. The registrar is where the verb/path → controller-method resolution actually happens; read it before you write production routes against it.README.md — usage examples.php artisan route:list after your first registration — this is the ground truth for what the package actually registered, and it will answer most questions faster than the docs.First use case
Replace an explicit CRUD block with one line. Instead of:
Route::get('posts', 'PostController@index')->name('posts.index');
Route::get('posts/create', 'PostController@create')->name('posts.create');
Route::post('posts', 'PostController@store')->name('posts.store');
Route::get('posts/{post}', 'PostController@show')->name('posts.show');
Route::get('posts/{post}/edit', 'PostController@edit')->name('posts.edit');
Route::put('posts/{post}', 'PostController@update')->name('posts.update');
Route::delete('posts/{post}', 'PostController@destroy')->name('posts.destroy');
you declare the resource once and let the package map verb + URI onto index / create / store / show / edit / update / destroy on PostController. Verify the method names it expects against src/ — the convention is the contract, and getting it wrong yields 404s or MethodNotAllowed, not a helpful error.
Register advanced routes last. These declarations are greedy by nature. Put them in a dedicated group at the bottom of routes/web.php (or your module's route file) so that explicit, named routes higher up win the match. If a route suddenly 404s after adding an advanced route, ordering is the first thing to check.
Wrap in a group for shared concerns. The package registers routes; it does not inherit your RouteServiceProvider middleware for free.
Route::middleware(['web', 'auth'])
->prefix('admin')
->name('admin.')
->group(function () {
// advanced route declarations here
});
This is also the cleanest way to apply auth, can: or throttle middleware per section without patching the package.
Use it for the boring 80%, not the interesting 20%. It shines on standard resource-shaped controllers. As soon as a route needs a custom name, a custom binding, a custom where() constraint, or a non-conventional method, write it out explicitly. Mixing the two styles in one file is normal and fine — just keep the explicit ones above the advanced block.
Combine with route model binding. Because the resolved method receives the route parameters like any other action, implicit binding on {post} works as long as the parameter name in your URI matches the type-hinted variable. This is the main reason to keep the URI patterns conventional.
Test at the HTTP layer, not the routing layer. Feature tests are the right safety net because the mapping is implicit:
public function test_update_route_reaches_controller(): void
{
$this->actingAs($user)
->put('/posts/1', ['title' => 'x'])
->assertOk();
}
A single smoke test per verb catches convention drift when you upgrade the package or Laravel.
Namespace resolution. On Laravel 8+ there is no automatic App\Http\Controllers prefix. Use fully-qualified controller class strings (PostController::class) in your declarations rather than the old string form — it survives the namespace change, gives you IDE navigation, and fails loudly at the declaration site instead of at dispatch.
php artisan route:cache freezes whatever was resolved. Always php artisan route:clear after editing declarations, and add it to your deploy script. If caching misbehaves, disable it temporarily to confirm the package isn't the cause.{any}-style catch-all, order matters and the catch-all must be absolutely last. Debug with php artisan route:list -v to see the registration order Laravel actually holds.PostController@patchThing exists until a request arrives. Consider a small test that iterates the expected verbs against each advanced route, or accept that 500s are your discovery mechanism.HEAD/OPTIONS and any Route::any-style behaviour are worth explicitly probing with curl -X OPTIONS if you have CORS or preflight requirements.app/Support/ and dropping the dependency. Keep that escape hatch in mind rather than treating this as infrastructure you can't remove.suffix-based method names), subclass or copy the registrar and register your own — cheaper than fighting the package's assumptions.How can I help you explore Laravel packages today?