What is MVC architecture in PHP ?

Hi friends, Today I am going to tell you how MVC architecture works. MVC stands or Model-View-Controller Architecture using which rich applications can be created. It was invented by Trygve Reenskaug. Generally while writing a dynamic website say in PHP (Here I am telling about MVC in PHP) we create some page like sample.php in which we put HTML code along with PHP where ever it is required.

In case of MVC, we need to maintain Presentation (View), Logic(Controller) and Database Activities (Model) separately. Before starting with MVC, you should have best knowledge of the language which you are going to use. Here I am using PHP.

The following flowchart will show you how MVC works.


Here, I am considering Codeigniter for MVC. Index.php is a front controller which actually receives all requests. It passes them to Routers where it determines that the which method and class to initialize for current request. It passes through Security where lot of filtration is done, such as stopping XSS requests and SQL Injections.

Once everything is clean, it pushes the request to an Important Application Controller where functions written in given classes are performed. There few other extra libraries which are attached to application controller such as Drivers, Models, Libraries, Helpers etc. As and when required in coding, a developer uses those libraries. Once the output is generated, it reaches at the Viewing function. View is nothing but a collection of HTML files which need to get load on user interface.

It also performs caching i.e. if the output of given class/method already exists in cache, then MVC will show cache page.

YouTube Preview Image

I know there are some controversies regarding using and not using MVC frameworks but I think MVC saves lot of time. Using MVC, one can get

  • Increased Performance
  • Capability
  • Flexibility
  • Security
  • Easy Upgradation
  • Structured Functioning

Following are some of the greatest MVC frameworks based in PHP.

  1. Codeigniter
  2. Yii Framework
  3. CakePHP
  4. Zend Framework
  5. Kohana
  6. Symphony
  7. Zoop
  8. TinyPHP
  9. PHPDevShell
  10. Prado

If you are creating a new Application, I recommend you to use MVC Frameworks.

Computer Software

Leave a Reply

Your email address will not be published.