Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel routes.php getting big [closed]

Tags:

php

laravel

As you continually add more and more routes to Routes.php it gets bigger and bigger. How do you organize them?

like image 262
Chris G. Avatar asked Feb 15 '13 22:02

Chris G.


1 Answers

I created a directory /application/routes/ and added files in there. Each file is just a set of routes. Then in routes.php I added the following code to include them all:

// Dynamically include all files in the routes directory foreach (new DirectoryIterator(__DIR__.DS.'routes') as $file) {     if (!$file->isDot() && !$file->isDir() && $file->getFilename() != '.gitignore')     {         require_once __DIR__.DS.'routes'.DS.$file->getFilename();     } } 
like image 77
coffe4u Avatar answered Oct 05 '22 11:10

coffe4u