Initially, I will say that it depends on your application architecture / functions and the scale of the websites you are going to make ...
Pros for a single routing file
- It complies with the rule: easier - always - better , therefore, if you really do not need several routing files, just do not.
- Multiple files can lead to conflict problems that can be resolved.
- My personal experience, when I myself worked on a home web application, I saved only one file in the application directory.
But what about multiple routing files?
However, you can find the legitimate use of multiple routing files if you have different plugins for handling content types (wiki, dashboard, gallery ...), and if they automatically implement routes (which will not change from the website to another).
In this case, you can use a small file specifically for each plug-in, which will be automatically combined with the application routing file (Note: as I mentioned earlier, you might encounter route conflicts between files). In my home application, I use this solution to handle the backend panel (administrator), I "solved" the collision problem by reserving the "/ admin /" route for the backend, and then all plugin routes get a prefix with it.
Symfony example for PHP-Framework
Don't take the following as βyou should do it like this,β but you can see how it is done in Symfony here: http://www.symfony-project.org/book/1_2/09-Links-and-the-Routing- System
I18n
Do you want to translate the URL? If so, remember me a simpler statement. Do you really need this? I know this may give you some SEO optimizer, but I donβt think it would be worth compressing. In this case, you can use 1 file per language for each application.
PS: what do you mean by "loaded models (in the case of a single router)?"
source share