While adding functionalities to my website, the need arose to better organize my routes in separate files, and for this reason I began to investigate how it is done and what I come to share with you today.
It is a very simple task since you will only have to make the modifications to the file
app / Providers / RouteServiceProvider.php in the mapWebRoutes function by adding require base_path ('routes / filename.php');
Example:
We create a file called user.php that will contain the routes related to the users, now we simply register it in the mapWebRoutes function as follows require base_path ('routes / user.php'); finally leaving the function like this
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(function ($router) {
require base_path('routes/usuario.php');
require base_path('routes/web.php');
});
}}
Any problem you can contact me in the comment box or directly on my social networks.
You can find more content like this on my Globalizations website
Top comments (0)