Source: medium.com

Laravel Routing Tips

Category: Laravel, api

If your Laravel route file is becoming too large you can pass in a file path to the route group() method. Laravel can cache your routes to make it quicker to find the code to run.

If you need to remove route caching you can use the command php artisan route:clear

For example, if you create a user Account area and have controllers for Account/ProfileController and Account/OrdersController, you can group these together with the following.

By default this to search for the User by using the primary key but you can change this to use say a slug parameter by using the method getRouteKeyName.
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