Search code examples
phpmodel-view-controllerno-framework

MVC large websites, use one controller...or many?


I have a pretty large site, and I am looking for the most time efficient way to manage it (I am the sole coder).

I am trying to devise a very simple MVC structure (i don't want to use a framework) to help keep all my code in order.

For a huge site, is it better to have only one controller to handle all the pages, or is it better and easier to split them up?

If just one, what is a good example of a non-framework controller?


Solution

  • I would split any logical divisions into different controllers - if it's all static pages, then serve it up with all the same 'static page' controller.

    If you have some static pages, a FAQ page (or section), a product list - use a controller for each different section. So the static pages would be pulled from flat files or a database by one controller, the FAQ pages would be generated from a FAQ table by another controller, the products and info would be generated by whatever the source for that is.

    Every time the way a page is generated or the data is accessed, use a different controller.

    Of course, class inheritance can be used to create the base class with the code needed by any controller.

    Not sure what you mean by a non-framework controller - I'd checkout the Zend (gasp) 'Framework', the MVC pattern, and even the controller itself, can be used apart from the rest of the framework.