constroller:
Controller class names are plural, CamelCased, and end in Controller.
ex: PeopleController and LatestArticlesController
URL Considerations for Controller Names:
single word controllers map easily to a simple lower case URL path.
ex: ApplesController is accessed from http://example.com/apples
File and Class Name Conventions:
The Controller class KissesAndHugsController would be found in a file named KissesAndHugsController.php
The Component class MyHandyComponent would be found in a file named MyHandyComponent.php
The Model class OptionValue would be found in a file named OptionValue.php
The Behavior class EspeciallyFunkableBehavior would be found in a file named EspeciallyFunkableBehavior.php
The View class SuperSimpleView would be found in a file named SuperSimpleView.php
The Helper class BestEverHelper would be found in a file named BestEverHelper.php
Model and Database Conventions:
Model class names are singular and CamelCased.
ex: Person, Post, User, CountyState, and PostsTags
Table names corresponding to CakePHP models are plural and underscored.
ex: people, posts, users, country_states, and posts_tags
Field names with two or more words are underscored
ex: first_name, last_name, user_name
View Conventions:
The getReady() function of the PeopleController class will look for a view template in /app/View/People/get_ready.ctp
_________________________________________________________________________________________
Database
Database tables are plural: “comments” or “user_comments” etc.
I recommend to stick to conventions and underscore + lowercase all table fields: “last_login” (instead of “lastLogin” or even worse “last login”) etc.
Models
Model names are singular and camelCased: “Comment or “UserComment” filename: “comment.php” or “user_comment.php”
Controllers
Model names are plural and camelCased: “Comments or “UserComments” filename: “comments_controller.php” or “user_comments_controller.php”
Controller actions should be underscored! “function admin_import_from_xml(){}”
Views
Views have an own folder for each controller – plural: “comments” or “user_comments”. Inside are the templates for the specific actions- underscored. filenames for example: “index.ctp” or “admin_index.ctp” (with prefix admin) or “admin_order_entries.ctp”
Libs
As long as namespaces are not an issue, they might conflict with existing model classes (they have no “Model” appended!) and other cake core classes or even some vendor files. I recommend to use the controller syntax here: Name – camelcased: “GoogleTranslateLib” filename: “google_translate_lib.php”
This way it won’t interfere with any Google class – or “FileLib” won’t interfere with core “File” class.
Behaviors
Name – camelcased: “GeoPlugin” filename: “geo_plugin.php”
They should not be similar to model names. Otherwise they might interfere with existing models. So use adjectives, verbs or plural names: “Ratable”, “Geocoded”, “Configurations”, …
Components
Name – camelcased: “GoogleTranslateComponent” filename: “google_translate.php”
They could interfere with models (and maybe behaviors). So it might make sense to use plural forms or forms that are not likely to be a model name.
Helpers
Name – camelcased: “GoogleHelper” filename: “google.php”
With the new 1.3 “$this->Helper” style they can now be anything you want. With a little modification of the core, at least. I like to call my helpers “MyHelper” if there are specific to a controller/module and it is not yet a plugin. Example: Conversations controller + Conversation model + MyConversation helper (as it is only needed inside this specific controller). Other helpers like “GoogleMap” might be used in several controllers, for instance.
Plugins
They should not be similar to controller names. Otherwise they might interfere with existing controllers. So use adjectives, verbs or singular names: “Rating”, “Setup”, “Configuration”, …
Constants
No matter if they are class constants or global constants, they are always uppercase and underscored: “MIN_USER_AGE” etc.
Variables
camelBacked: $userComment
The first letter is uppercase if the variable represents an object: $File = new File();
$GeoPlugin = new GeoPluginLib();
Layout/Script
CSS classes/ids: I use camelBacked style here, too: <div id="someId"></div>
But thats purely a matter of taste. I like to use it in IDs because I can easily attach “-x” (the record id) and split it afterwards on “-” to get the record id in JS: … id=”someId-2″… comes in handy sometimes
Test Cases
Same as the original file – only with “.test” appended to it: “google_translate_lib.test.php” for instance.