I have built a framework for my applications that has been working well, and I have always referred to it in my mind as an MVC. However, after reading some more on what an MVC is (not that I didn't to start with, but I gave it a very brief overview, and looked at other frameworks that used the mvc pattern), and it has given me pause for thought.

The structure is as follows:

The framework has a bootstrap that loads the required files for the framework and the initiation file for the application (app_bootstrap.php).

The app_bootstrap.php file has three functions.

First, it creates constants for the framework to use (i.e. Database connection setup, profiling setup, base url path, and internal file paths).

Second, it requires all the files that would be pertinent to the application, primarily, what I have called "model" classes which contain information on the name and structure of tables in the database, validation rules, associations to other "models", etc. These "models" extend an abstract class that contains static functions for selecting and creating rows from the database, which will create instances of an entity class that deals with the row, such as __get, __has, __set, __unset for fetching columns and associations, and save and delete for saving the row changes to the database.

Third, it calls functions within the router.php file that will setup bindings for environmental data (like the url, user login status, ssl, ajax, cookie existence, etc) to "controller" classes.

The framework then runs an execution function within router.php that will go through the defined environmental data rules, and determine which "controller" to load, if it finds one, it will require the file (from the application/controllers directory, throwing an error if not found) and call the class with the appropriate entry point function (index is none defined), or throw a 404 error.

Once the "controller" has been started, there are no more functions that the framework will execute, and once the "controller" has finished, the program will end (unless the profiling has been activated, where it will output the data, then end). But the framework provides functions to the "controller", and to name a few, an input class (for dealing with all input, such as $_GET, $_POST or $_SERVER variables, cookies, user agent, remote ip, etc, as well as providing a sanitized interface), an output class (for headers, cookies, status messages, etc), a queryBuilder class (for creating queries to the database in the event functionality that can't be done within the "model"), and a view class (for parsing variables into a view for rendering and returning to the client).

But after reading some more information on MVC's, it appears that the router.php acts similarly to a Controller, the "controller" acts like the model, the "model" acts like an ORM, and the view is pretty much correct. So, would this framework still be classed as an MVC, or does it fit under another pattern (if there is such a pattern)?

1 Answer 1


Your Router is what's called the Front Controller; it handles the upfront processing of the request and hands it to your Controllers which from a 10k foot view sounds like a true MVC controller. Many developers leverage the same object model that the O/RM uses, but it sounds like your "Entity" classes are the true Model. Either way you look at it, it sounds like a valid MVC implementation to me.

One thing to note about software patterns... In general the pattern provides a guideline but not a strict implementation. It's always subject to the interpretation of the developer. Similar to Alexander's original work that software patterns were based on. Alexander's patterns described general solutions to a common problem in building spaces, but the actual realization of those solutions were subject to the aestethic of the builder.

  • Well, the "Entity" Class is not an abstract class, but is created by the abstract code of the Model abstract class (which has a reference to the caller class for information), but I thought the Model was supposed to provide the functionality to the controller so the controller didn't have to have to do much leg work. Is that interpretation of the definition of "model" within the MVC context not correct?
    – topherg
    Apr 22, 2013 at 17:16
  • 1
    Model is not a class or object. Model is a layer, which contains all of the domain business logic. If you code has "ORM models" then it is not MVC, just a sad clone of Rails stupidity.
    – mefisto
    Apr 22, 2013 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.