Welcome Guest, Not a member yet? Register   Sign In
How many routes are too many?
#1

[eluser]Sergio B[/eluser]
Hello,

I'm currently building a web site in CodeIngiter. Trying to keep all URLs as SEO friendly as possible I found myself having a good handful of routes in my routes.php file and now I'm wondering How many routes are too many?

I'm certain that my current server breezes through the routes file in a blink but maybe when the site traffic grow it will hurt the site performance,

I was thinking of moving some of the site sections to a sub domain to avoid having a lot of routes but this will cost me maybe a week of work. So I want to know if 50 routes are too many routes or 100 or what is a number of routes to be considered big.
#2

[eluser]PhilTem[/eluser]
I don't know how many routes are too many. But I'd say, if you're routing every controller to something else you definitely have too many. Or if you have more routes configured than you have controller-method-combinations.

That would definitely be too much.

And it'd proof that you've designed your app wrong, since you would not need routes if you named your controllers right i.e. had a second thought on organizing before writing all your code Wink

On the other hand, I'd say, the correct answer is it depends on how you're using your app. If you're using HMVC you might end up with more routes than using basic MVC.
My projects so far have only a very limited, lower range, two-digit number of routes (for several dozen controller-method-combinations)

Have a look at PyroCMS and Bonfire which are kinda huge apps written in CI with some routes as well. This way you'll see how it's done in big apps.
#3

[eluser]Sergio B[/eluser]
First of all my apologies for not providing enough details from the beginning I thought they wold be annoying for a question I thought was simple.

Well I certainly do not have more routes than controllers and methods. But the thing is that the site is a multi-language site and thus there are routes for each of the languages, like this:

Code:
$route["terms-and-conditions"] = "terms/english";
$route["terminos-y-condiciones"] = "terms/spanish";
$route["termini-e-condizioni"] = "terms/italian";

Also some controllers in the admin module of the site have names with underscores but I don't want underscores in the URL so for example I have routes like these:

Code:
$route["admin/image-gallery"] = "admin/image_gallery";
$route["admin/home/banners"] = "admin/home_banners";

Is basically pure eye candy. So I was thinking of moving the admin module to a sub domain to avoid having a lot of routes in the site. That is why I wanted to know how many routes are too many. If I have around 70 routes is that okay or is it too much?
#4

[eluser]PhilTem[/eluser]
Wow, I think, from a general perspective, 70 routes is in the higher range of number of routes.
But, regarding your multi-language site, you should have a look at

http://maestric.com/doc/php/codeigniter_i18n

which solves the problem of internationalization easily. Of course, this only makes the pages' content multi-language, not the URIs, so if you want to also have the URIs set up to be multi-language, you might want to extend the router- and loader-class to do some fancy magic stuff which I don't even know yet what it should do. But basically try to translate every Non-English URI to an English URI and then display the content.

Might also speed up your system a little Wink

And for your admin-case, you could also extend the router-class and make it replace any dash with an underscore so you don't have to route every dashed-url Wink




Theme © iAndrew 2016 - Forum software by © MyBB