Welcome Guest, Not a member yet? Register   Sign In
Controller or URI Routes?
#1

[eluser]jtkendall[/eluser]
Hi, this is probably more of a general MVC question than CodeIgniter specific, but since I use CI I figured I should ask here.

Right now I have a controller called "administrator" and I want all of the administrative functions to appear under the administrator controller in the URI. So I've been building all of my administrative functions under the one controller (and it's quite large). I read about the URI routing options (after I had spent a week on the project).

My question is, which is better from a MVC perspective and from a processing perspective. To use one controller with all of the grouped functionality in it, or to use multiple controllers and URI routing to keep the URI appearance?
#2

[eluser]Bramme[/eluser]
Hi, I've had a similar issue with my latest project: the frontend off the website was based off of one controller but my adminstration had multiple. What I did was put all my adminstration controllers in a subdirectory in my applications/controllers directory called admin, you can then point your uri to mysite.com/subdir/controller/method
#3

[eluser]beemr[/eluser]
CI controllers don't instantiate other controllers, so having all of your functions in one controller is required if you want to have common functions or call different methods.

You could move all of your common accessory methods to a Super Controller. See this thread for more on that design pattern.
#4

[eluser]Crafter[/eluser]
It comes down to your application design.

See this related post : http://ellislab.com/forums/viewthread/89613/
#5

[eluser]jtkendall[/eluser]
Thanks for the responses everyone. I tried Super Controller idea and it worked great until my boss threw a wrench into the plan demanding everything be modular. So I'm on rewrite 4.5 of the application, this time using HMVC (http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/) and Custom URL Routes, and it's working great.




Theme © iAndrew 2016 - Forum software by © MyBB