I have already mentioned about MVC framework and CakePHP in one of my articles, therefore I am going to discuss more about it today. Please note, CakePHP is one of the MVC frameworks written in PHP. Don't get confused that MVC framework means CakePHP.
MVC
MVC stands for Model View Controller. It is ultimately a software design pattern where you can separate your code and make it reusable, thus making you write less code.
Model
For each and every database table, we have a separate model - this is what represents a particular database table. And according to the naming convention of CakePHP, its name is always the singular of its table's name. For example, if the name of the database table is 'users', the model name will be 'User' (first character of the name is always in uppercase).
Controller
A controller is used for managing the logic of a certain section of your application. Generally, it is used for managing a single model. For example, you have a model named 'User', and you will require a controller for managing the logic of user registrations, logins, log outs, account settings, etc. According to the naming convention of CakePHP, controller names are always plural. In this case, the controller name would be 'Users'.
View
A view is a page template, usually named after its controller's action (a controller is a php class with many functions known as its actions). As you can guess, this is responsible for the visual output of your application.
I will show you how to install CakePHP (including the php files) in my next article.
0 comments:
Post a Comment