views

I have a major project which has around 600 routes and leaving them all in one web.php file is just not an option.
It is too difficult to manage. Finding a particular route can take a long time.
The answer is really fairly simple. In my routes directory I have a subdirectory which I called "inc_routes"
As an example in there I have a file dbase.php which has the following code:
<?php
Route::group(['prefix' => 'admin'], function () { Route::get('dbase','DBaseController@index')->name('dbase'); Route::get('dbase.backup','DBaseController@backup')->name('dbase.backup');
});
There are two ways I can handle this. I can either get rid of the the prefix group in the file above and add this to my web.php file:
Route::prefix('/admin')->group(__DIR__.'/inc_routes/dbase.php);
or leave the prefix in the file by passing a null for the prefix:
Route::group([],__DIR__.'/inc_routes/dbase.php);
It is that simple. And you can use the same thing for your api file!
Facebook Conversations
Disqus Conversations