Leandro Garcia
Leandro Garcia

Reputation: 3228

Extending Lumen's web routes file

By the docs, it is stated that routes should be placed in web/routes.php. I wonder, can I organize the routes by class or modules the way I wanted?

Upvotes: 2

Views: 431

Answers (1)

ayip
ayip

Reputation: 2543

Here is how I did it in my lumen 5.4 app. For each module/controller class I have a different Route.php file under App\Http\Routes\. And in my App\Http\routes.php, I load them as

$app->group(
    [],
    function () use ($app) {
        foreach (glob(__DIR__ . '/Routes/*.php') as $filename) {
            include $filename;
        }
    }
);

Upvotes: 1

Related Questions