I was contributing to a project that now has a routes.php file with like over 800 lines of routes. I was wondering if Laravel had a specific convention or a way to organize this so it doesn't have to have all routes in one large confusing file?
Separate routes for large applications into multiple smaller route partial files that are automatically loaded at runtime.
Also you can
Useful examples
split routes in different parts
Also i can recommend route caching for performance
The best ways are groups and don't list every single route but use controller routes. http://laravel.com/docs/4.2/routing#route-groups http://laravel.com/docs/4.2/controllers#implicit-controllers
If this doesn't help it's possible to split this file into multiple files, for example: routes/users.php, routes/posts.php and so on, and include these into the original routes.php
Also it would help to put some routes in different files. For example, you could create a folder called routes in your app folder, then add files in that folder. I usually have one file for authentication routes, then other files for the high level navigation items of the site.
don't forget to require those files in app/start/global.php
/*
|-------------------------------------------------------------------------
| in app/start/global.php
|-------------------------------------------------------------------------
|
*/
require app_path( 'routes/auth.php'); // Auth routes
require app_path( 'routes/articles.php'); // Article routes
maybe you should also consider using controller along side this technique to further slim you routes
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.