I am starting to build my web application progressively, adding routes and other routes to the router. The application is not a single page application, in the sense that it offers relatively independent features.
For example, if you had to build an application including a wiki, a dashboard (and settings), as well as a game using the wiki's data, should you use only one router with many routes? or should you split the application into small sub-applications with their own controllers?
In both cases, how to handle the problem of i18n? and loaded bootstrapped models (in case of a single router)?
Originally, I'll say it depends on your application architecture/features and the scale of websites you are going to do...
You could however find a legitimate usage to multiple routing files if you have different plugins to handle content-types (wiki, dashboard, gallery...), and if they automatically implement routes (that won't change from a website to another).
In this case you could use small file specifically for each plugins that will be automatically merged to the app routing file (Note: as I previously mentionned, by doing this you could experience route collisions between files). In my homemade app, I'm using this solution to handle the backend (admin) panel, I "solved" the collision problem, by reserving the "/admin/" route for the backend then all plugin's routes get prefixed with it.
Don't take the following as a "you should do it like this" but you can look how it's done in Symfony here: http://www.symfony-project.org/book/1_2/09-Links-and-the-Routing-System
# default rules
homepage:
url: /
param: { module: default, action: index }
default_symfony:
url: /symfony/:action/*
param: { module: default }
default_index:
url: /:module
param: { action: index }
default:
url: /:module/:action/*
Are you willing to translate urls ? If yes, remember me simpler-is-better statement. Do you really need it ? I'm aware that it may grant you some SEO boost, but I don't think it would be worth the squeeze. In this case, you could use 1 file per language, per app.
PS: what do you mean by "bootstrapped models (in case of a single router)?"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With