Wednesday, December 26, 2012

Importance of Frameworks in PHP

This is to all PHP developers who are not at all using any frameworks for their development. For those who are just sticking on their PHP basics and developing projects (may be small, medium or large).

May be you have heard about some frameworks in PHP, like Yii, CakePHP, Zend etc. All these are based on MVC Framework. MVC is the abbreviated form of  model, view controller. 

The moment we hear of framework we definitely search it, we just make a try, but we find it very difficult to follow and then finally we drop it and move towards our core level PHP. Please don't do that. All software company needs PHP Developers with skills in any of the above specified frameworks. So better learn it before you search for a job.

What is MVC Framework?

It is a software architectural pattern used in software engineering. It splits our entire project or application into 3 layers - model layer, view layer and controller layer. 

Now you may think internally, why should I split them into layers. My answer is : to increase flexibility and maintainability of code. It turns the application into modular and rapidly developing package. Designers and developers can work simultaneously. New features can be added easily, etc.

General Representation of MVC framework

Model Layer - It acts as a first layer of interaction with the database you have defined for your application. It take care of tasks such as saving the data, retrieving the data, searching the data etc. It defines relationships between tables of the database etc. 

View Layer - Represents the layer where you define how you want to present the data to the users. For example, as the Model layer returns a set of data, the view would use it to render a HTML page containing it. Please note that it does not limit to the HTML representation. 

Controller Layer - As you can see in the figure the Controller layer handles requests from users. It gives the response with the help of both Model Layer and View Layer. It actually manages all resources which are needed to complete the task. 

This is just an into. I know you may be confused now, and may be you are about to quit the idea of using the frameworks. Please don't quit. If you have never built an application this way, it takes some time getting used to, but once you build your first application using any of the frameworks, may be CakePHP, or Yii, you will never do it any other way.

I am working on CakePHP. It's very simple to understand. Very good for beginners. 
As per the survey Yii framework is at the top. There are other frameworks also, like ZendCodeIgniterSymphony etc. 

Select one of the frameworks, download the stable version of the selected framework and build one application. Then only you will understand the basics. Once you get the idea of one framework you can then master any framework within no time. 

So best of luck..

No comments:

Post a Comment