on Basics Tutorials

CakePHP from scratch: Basic principles

6 comments
hacker
Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInShare on RedditShare on StumbleUpon

In my first tutorial I showed you how to install and configure CakePHP. Let me explain some more basics today.

I am taking examples from official CakePHP pages to show you how CakePHP Model-View-Controller pattern work. This examples explain the basic principles that you should try to remember. If you never used MVC pattern before it is a little bit confusing, but you will understand as soon as we begin developing a real life application in my next tutorial.

CakePHP follows the MVC software design pattern. Programming using MVC separates your application into three main parts:

CakePHP MVC pattern

Figure: 1 shows an example of a bare-bones MVC request in CakePHP. To illustrate, assume a client named “Ricardo” just clicked on the “Buy A Custom Cake Now!” link on your application’s home page.

Almost every request to your application will follow this basic pattern. I’ll add some details later on which are specific to CakePHP, so keep this in mind as we proceed.

Why use MVC?
Because it is a tried and true software design pattern that turns an application into a maintainable, modular, rapidly developed package. Crafting application tasks into separate models, views, and controllers makes your application very light on its feet. New features are easily added, and new faces on old features are a snap. The modular and separate design also allows developers and designers to work simultaneously, including the ability to rapidly prototype. Separation also allows developers to make changes in one part of the application without affecting others.

Stay tuned as we will continue the series with developing a real life web application.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInShare on RedditShare on StumbleUpon