There are many ways using which you can group your routes in Laravel right now. Consider the following group of routes. use Illuminate\Support\Facades\Route; Route::get('/', [BookController::class, 'index']); Route::get('/books/{id}', [BookController::class, 'show']); Route::get('/books/search/{search}', [BookController::class, 'search']); Route::post('/book', [BookController::class, 'store']); As you can tell, we have four routes to manage books and if you notice, all of these routes have one thing in common.

use Illuminate\Support\Facades\Route; use App\Http\Controllers\BookController; Route::controller(BookController::class)->group(function () { Route::get('/', 'index'); Route::get('/books/{id}', 'show'); Route::get('/books/search/{search}', 'search'); Route::post('/book', 'store'); }); As you can tell, by using this approach now you have all the routes, that use the same controller, are under the same group.

Now, if you’re grouping routes by controllers using the above approach and if you specify the controller on the route once again, it will override the group controller.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners