CakePHP Conventions


AREA Class Name Extends
MODEL

{model name singular}

user

AppModel
VIEW
none none
CONTROLLER

{model name plural}_controller

users_controller

AppController
AREA Filename and Location in Application
MODEL app/models/{model name}.php
VIEW app/views/{controller name}/{view name}.ctp
CONTROLLER app/controllers/{controller name}_controller.php
The {view name} in {view name}.ctp is also one of the controller function names

Model – Handles all database functions

View – Handles the presentation layer

Controller – Processes and responds to events (typically user actions) and may indirectly invoke changes on the model

Additional Info:
All the tables in the database have to be plural and underscored. For example queries, processes and users. But this can be customized please refer here
All primary key attribute in the database is expected to be “id” but some prefer the primary key to be table_name_singular_id which will also work as long as you set the $primaryKey variable in the model definition.

 

For a more detailed info about CakePHP Conventions refer here

Advertisements

3 Responses to “CakePHP Conventions”

  1. The middle column of your first table is missing the ‘view’ information 🙂

  2. myleskadusale Says:

    Opps typo 🙂 Thanks Richard

  3. […] For a different look at CakePHP Conventions Click Here […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: