Naming Convention In Cake PHP

December 29, 2012
Posted by admin 2:57 PM

 "Hi readers when I have started to work with cake PHP I found some difficulty in work with cake PHP Especially with its naming convention of controller and models and with its inbuilt functions. Then I have decided to write this article in a easy way so that u you readers easily understand the cake PHP.

Thanks waiting for your feedback 

Naming the Database Table:

The table names are plural, lowercased and with underscores. If there are two or more words then it should be underscored.

Ex : people , trees, big_trees.

 

Naming the Model Classname:

The mode classnames  must be singular and camel cased.

Ex :  Person ,Tree, BigTree.

class  Person extends AppModel

{

}

Class  Tree  extends AppModel

{

}

Class  BigTree  extends AppModel

{

}

 

 

The file name for these models should be in lowercase letters and filename with two or more words should be underscored.

Ex  :  person.php,tree.php,big_tree.php

 

The tablename for these models should be plural and in lowercase letters .If there are two or more words then it should be underscored.

Ex : people , trees, big_trees.

 

Naming the Controller Classname:

Controller classnames are plural ,camelcased and always end in Controller.

Ex : PeopleController , TreesController , BigTreesController.

class  People  extends AppController

{

}

class Trees  extends AppController

{

}

Class  BigTrees  extends AppController

{

}

 

 

File name of these controllers are lowercased and filename with two or more words should be underscored.

Ex : people.php,trees.php,big_trees.php.