Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Čamo's avatar
Level 3

Separate route file not work

Hi I wanted to add new file to routes directory for better organization of app routes. Documentation says that Laravel load all files from routes directory automaticaly. But Its seems it does not work. I am getting not found excaption. If I add this line to other routes file it works fine but it seems little dumb.

Route::group([], __DIR__ . '/tenant-web-app.php');

What am I doing wrong?

0 likes
9 replies
jaseofspades88's avatar

In your RouteServiceProvider you can explicitly assign files. Like so:

$this->routes(function () {
    Route::middleware('web')
        ->group(base_path('routes/tenant-web-app.php'));
});
1 like
jaseofspades88's avatar

Another thing I see in applications and advise against is then inclusion of a separate route file, e.g. web.php. This causes a lot of problems when bootstrapping the routes during testing, in some cases.

require('admin.php'); //advise against doing this in route files
1 like
jaseofspades88's avatar

@Čamo Good to hear. If this answers your question mark it so it will help others struggling with this problem in the future.

Please or to participate in this conversation.