Cake Conventions
This is the Cake Conventions from the old wiki site.
- tables names are plural and lowercased
- model names singular and CamelCased: ModelName
- model filenames are singular and underscored: model_name.php
- controller names are plural and CamelCased with *Controller* appended: ControllerNamesController
- controller filenames are plural and underscored with *controller* appended: controller_names_controller.php
- associations should use the ModelName, and the order should match the order of the foreignKeys: var $belongsTo = 'User';
- foreign keys should always be: table_name_in_singular_form_id: user_id (foreign key) -> users (table)
- many-to-many join tables should be named: alphabetically_first_table_plural_alphabetically_second_table_plural ie: tags_users
- columns in many-to-many join tables should be named like other foreign keys ie: tag_id and user_id
- columns named created and modified will automatically be populated correctly
- components should be CamelCased: MyComponent : my_component.php : var $components = array('MyComponent'); $this->MyComponent->method();
- helpers should be CamelCased: MyHelper: my_helper.php: var $helpers = array('MyHelper'); $myHelper->method();
Comments
Comment
1 An Undocumented Convention
A column named "name" or "title" will automagically be used as the description for a foreign key in scaffolding or a baked view.
Comment
2 1 More Convention
Question
3 view using many controllers
thanx
Question
4 About cakephp
Comment
5 piece of cake
LINK TO READ:http://personalmoneystore.com/moneyblog/2009/04/16/princess-louise-wedding-cake/
Comment
6 List of prohibited/protected class names
appappcontroller
appmodel
behaviorcollection
cache
cacheengine
cakelog
cakesession
classregistry
component
configure
connectionmanager
controller
datasource
debugger
dispatcher
file
fileengine
folder
helper
inflector
model
modelbehavior
object
overloadable
overloadable2
router
security
sessioncomponent
set
string
See http://groups.google.com/group/cake-php/msg/8d149a246d46d3cf
Question
7 Is it allowed to use "-" in table names?
Comment
8 cakes
social commerce
Comment
9 i find it interesting