Naming Conventions in CakePHP

We need to follow the naming conventions as specified in this blog for all our CakePHP projects. This will help us in getting certain benefits of CakePHP and will help us in maintaining consistency too.

Consider an example of users management, where we provide insert/update/delete/view and list for users. So in this case, our naming convention will be as below:

Model

Table Name - users (Plural and Underscored)
Field Name - first_name, last_name etc.. (Lowercase and Underscored)
Model/Table Class Name - UsersTable (Plural, PascalCased and end in Table)
Entity Class Name - User (Singular, PascalCased and have no suffix)

Controller

Class Name - UsersController (Plural, PascalCased and end with “Controller”)
URLs and Controller Method Names
For users data table page
URL - /users (this will automatically be mapped with index method)
Method - index()
For add user page
URL - /users/add
Method - add()
For edit/update user page
URL - /users/update/
Method - update()
For delete user
URL - /users/delete/
Method - delete()
For view user page
URL - /users/view/
Method - view()

Views

Directory Name - Users (Plural and PascalCased)
Files Names - index.ctp, add.ctp, update.ctp and view.ctp (Small and Underscored)