Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
975 views

Cakephp Cheatsheet

The document outlines naming conventions and file structures for different parts of a CakePHP application including models, controllers, views, components and helpers. It provides details on class names, file names, paths and common methods.

Uploaded by

Mwangi Wanjohi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
975 views

Cakephp Cheatsheet

The document outlines naming conventions and file structures for different parts of a CakePHP application including models, controllers, views, components and helpers. It provides details on class names, file names, paths and common methods.

Uploaded by

Mwangi Wanjohi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CakePHP Naming Conventions

cong ('le_name')

Global Functions
up ('string') r ('search', 'replace', 'text') pr (array) am (array, [array, array]) env ('HTTP_HEADER')
cache (path, data, expires, [target])

Models
Class Name: singular, camel cased (LineItem, Person) File Name: singular, underscored (line_item.php, person.php) Table Name: plural, underscored (line_items, people)

Controllers
Class Name: plural, camel cased, ends in "Controller"

Views
Path: controller name, underscored (app/views/line_items/<le>, app/ views/people/<le>) File Name: action name, lowercase (index.thtml, view.thtml)

uses ('le_name') vendor ('le_name') debug ('message') a (element, [element, element]) aa (key, value, [key, value]) e ('message') low ('STRING')

(LineItemsController, People Controller)

File Name: plural, underscored


(line_items_controller.php, people_controller.php)

clearCache ([params, type, ext]) countdim (array)

Model
Properties $cacheQueries $data $displayField $id $name $primaryKey Methods $recursive $useDbCong $useTable $validate $validationErrors $_tableInfo Association Properties $belongsTo $hasAndBelongsToMany $hasMany $hasOne

Controller
Properties $name $autoLayout $base $cacheAction $data $here $output $params $plugin $view $webroot Methods $action $autoRender $beforeFilter $components $helpers $layout $pageTitle $persistModel $uses $viewPath Properties $action $autoRender $controller $hasRendered $here $loaded $name $params $plugin $themeWeb $viewPath Methods

View
$autoLayout $base $ext $helpers $layout $models $pageTitle $parent $subDir $uses

bindModel (params) create ( ) delete (id, [cascade]) escapeField (eld) execute (data) exists ( ) eld (name, conditions, order) nd ([conditions, elds, order, recursive])
ndAll ([conditions, elds, order, limit, page, recur...])

getLastInsertID ( ) getNumRows ( ) hasAny ([conditions]) hasField (name) invalidate (eld) invalidFields ([data]) isForeignKey (eld) loadInfo ( ) query ([sql]) read ([elds, id]) remove ([id, cascade]) save ([data, validate, eldList]) saveField ([name, value, validate]) set (one, [two]) setDataSource (dataSource) setSource (tableName) unbindModel (params) validates ([data])

ndAllThreaded([conditions, elds, sort]) ndCount ([conditions, recursive]) ndNeighbours (conditions, eld, value)
generateList ([conditions, order, limit, keyPath, val...])

getAffectedRows ( ) getColumnType (column) getColumnTypes ( ) getDisplayField ( ) getID ([list])

cleanUpFields ( ) constructClasses ( ) ash (message, url, [pause]) ashOut (message, url, [pause]) generateFieldNames (data, doCreateO...) postConditions (data) redirect (url, [status]) referer ([default, local]) render([action, layout, le]) set (one, [two]) setAction (action, [param, param, param]) validate ( ) validateErrors ( )

element (name) error (code, name, message) pluginView (action, layout) render ([action, layout, le]) renderCache (lename, timeStart) renderElement (name, [params]) renderLayout (content_for_layout) setLayout (layout)

Helper
Availability: View only

Callbacks afterDelete ( ) beforeDelete ( ) beforeFind (&qu..) afterFind (results)

beforeSave ( ) beforeValidate ( )

afterSave ( )

Callbacks beforeFilter ( ) afterFilter ( )

beforeRender ( )

Global Constants
Core Denes
ACL_CLASSNAME ACL_FILENAME AUTO_SESSION CACHE_CHECK CAKE_ADMIN CAKE_SECURITY
CAKE_SESSION_COOKIE
CAKE_SESSION_STRING

Paths
APP APP_DIR APP_PATH CACHE CAKE COMPONENTS CONFIGS CONTROLLER_TESTS CONTROLLERS CSS ELEMENTS HELPER_TESTS HELPERS

Component
INFLECTIONS JS LAYOUTS LIB_TESTS LIBS LOGS MODEL_TESTS MODELS SCRIPTS TESTS TMP VENDORS VIEWS Availability: Controller / View

CAKE_SESSION_TABLE
CAKE_SESSION_TIMEOUT

Properties
$disableStartup

COMPRESS_CSS DEBUG LOG_ERROR MAX_MD5SIZE WEBSERVICES

Callbacks
startup (&controller)

Properties $tags $base $here $action $themeWeb $view $webroot $params $data $plugin Callbacks
afterRender ( )

CAKE_SESSION_SAVE

Conventions
Class Name: MyCoolComponent
Path: app/controllers/components/my_cool.php

Conventions
Class Name: MyCoolHelper Path: app/views/helpers/my_cool.php

Webroot Congurable Paths


CORE_PATH ROOT WWW_ROOT WEBROOT_DIR

Usage
Controller: $this->MyCool->method( ); View: $this->controller->MyCool->method( );

Usage
View: $myCool->method( );

CAKE_CORE_INCLUDE_PATH

Copyright 2006, Cake Software Foundation

You might also like