Samantha Tec Blog

Flat world, next creative idea

Impliment MVC pattern in PHP

Basically PHP is self-disciplined language so we can use PHP for high level enterprise projects or one page script. When PHP involves with Enterprise projects so then we have to useĀ  enterprise architecture .

MVC stands for Model , View and controller . View is Html controllers for PHP application , Controllers normally grab the request and call for Model layer . Model layer can be split into DAO ,Service and Entity layers

Most of the latest PHP frameworks support to developĀ  MVC applications. Zend and Symfony facilitate with Front Controller pattern and MVC pattern. Front Controller pattern means all application requests come through one single file ( basically via index.php file)

View

Xhtml , Javascript , CSS are used in this layer. Modern applications replace java script with browser-compatibility Jquery. CSS chunks it for screen.css , form.css, table.css and print.css .

Controller

Controller is for handling the actions of an application. Zend Framework provide Zend_Controller_Action base class and Symfony provide sfActions base class for handling incoming request of application

Model

Doctrine ORM come to picture and replaces DAO and Entity layer of modern days PHP application. All the relations can be defined in .yml file and auto-generate the entity class and populate the widely used database. Doctrine is provided with DQL which is portable in many popular databases.

we can implement Service layer of the application by applying widely-known design patterns.


4 comments

4 Comments so far

  1. Garretot January 29th, 2010 2:47 pm

    Hi there,
    Interesting, did you plan to continue this article?
    Thanks
    Garretot

  2. admin January 29th, 2010 4:02 pm

    Hi
    Thanks for your comment .. I’m planing to continue it with ‘How to apply design patterns in model layer’.

    Samantha

  3. John March 10th, 2010 10:59 am

    Don’t forget CakePHP! Cake’s tight MVC structure is based on ROR which has in turn heavily influenced a lot of PHP frameworks.

    Good post

  4. free registry cleaner August 6th, 2010 3:42 am

    I’ve already bookmark this article and will definitely refer this article to all my close friends and colleagues. Thanks for posting!

Leave a reply