PHP MVC

MVC basic flow

All PHP MVC follows same idea. Functional programming is a tedious task and there are some decent benefits of MVC over Procedural OR Functional programming.

For all MVC like Codeigniter & Laravel has same idea as described below.

  1. When User enter any URL , It goes to Router and it’s responsibility is to break URL into Controllers, Methods & Parameters. Also this Router has default Controller & Default Method.
  2. Once Controllers & Methods are defined , system loads that controller where related Model is also imported in that controller file.
  3. So now we have Controller & it’s Model. Call that methods of controllers and process for DB events. Prepare a array of values/results
  4. & pass that array to view file which is going to be load on related controller when we have processed for DB operations. The View file is loaded in many parts like Header, Body & Footer to avoid complexity.

So by this way ROUTER calls CONTROLLERS, CONTROLLERS loads MODEL, call related METHODS & Process for DB and PASS all result array to VIEW.

Besides all this, we use some .htacess files to protect system directories & files and to redirect URLs.

That’s it.