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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners