Naming convention in cakephp
To get Maximum advantages from Cakephp then we need to follow some basic naming convention that cakephp rules says.
Naming convention follows principles of following section of cakephp
- Database name
- Controller file name
- Controller Class Name
- View file name
- Model file name
- Model Class name
Naming convention of Controller file in cakephp
In cakephp the controller file always follows plural naming convention.
CASE-1:
If a table name is orders in your database,then your controller file name should written like this
orders_controller.php
Then the Class name should be written like this
OrdersController
Tips: our table name is order , but at the time of naming the class name ,i have written it as Orders .
So always keep your table name plural (optional) and lower case.but always starts the class name as Upper case
like in OrdersController class ,the first letter O is capital but in my database the first letter was lower case.
At the timing of naming the class ,we should attach the name Controller to the table name,
like i have attached the word Controller to Orders ,so it becomes OrdersController.
CASE-2:
If a table name is users in your database,then your controller file name should written like this
users_controller.php
So from above 2 case we found that what ever the table name,our controller file name should contain a S following singular name.
Then the class name will be
UsersController
CASE-3:
If your database table consist of two words like following example
suppose the table name is user_profile , then the controller name would be
user_profiles_controller.php
Then the class name will be
UserProfilessController
0 Comment(s)