0% found this document useful (0 votes)
107 views1 page

CakePHP 1.2 Cheatsheet

This document summarizes key concepts in CakePHP including configuration, models, controllers, views, helpers and global functions. It outlines conventions for naming files, classes, methods and properties. It also lists common model, controller and component callbacks and properties. Key classes and their relationships are defined for the core MVC framework.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views1 page

CakePHP 1.2 Cheatsheet

This document summarizes key concepts in CakePHP including configuration, models, controllers, views, helpers and global functions. It outlines conventions for naming files, classes, methods and properties. It also lists common model, controller and component callbacks and properties. Key classes and their relationships are defined for the core MVC framework.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

The CheatSheet - CakePHP 1.

2
Config
debug App.encoding App.baseUrl App.dir Cache.check Cache.disable Acl.classname Acl.database Routing.admin Session.start Session.save Session.checkAgent Session.cookie Session.timeout Security.level Security.salt Asset.filter.js Asset.filter.css

Core

Properties
$cacheQueries $data $displayField $id $name $primaryKey $recursive $useDbConfig $useTable $validate $validationErrors $_schema

Model
Relationships
$belongsTo $hasAndBelongsToMany $hasMany $hasOne

Controller
Properties
$name $action $autoLayout $autoRender $base $cacheAction $components $data $helpers $here $layout $output $pageTitle $params $persistModel $plugin $uses $view $viewPath $webroot

View
$action $autoLayout $autoRender $base $ext $hasRendered $helpers $here $layout $loaded

Properties
$models $name $pageTitle $params $plugin $subDir $themeWeb $uses $viewPath

Models
Class:

Conventions

singular, camel cased (LineItem, Person) singular, underscored (line_item.php, person.php) plural, underscored (line_items, people)

File:

Table:

Methods
bind(params) create([data]) delete([id, cascade]) deleteAll(conditions, [cascade, callbacks]) escapeField(field) exists() field(name, conditions, order) find(type, [options]) getAffectedRows() getAssociated([type]) getColumnType(column) getInsertID() getNumRows() hasAny([conditions]) hasField(name) invalidate(field) invalidFields([data]) isForeignKey(field) isUnique(fields, [or]) query([sql]) read([fields, id]) save([data, options]) saveAll([data, options]) saveField([name, value, validate]) schema([field]) set(one, [two]) setDataSource(dataSource) setSource(tableName) unbindModel(params, [reset]) updateAll(fields, [conditions]) updateCounterCache([keys, created]) validates([options])

Methods
addScript (name, [content]) element (name, [params, loadHelpers]) error (code, name, message) getVar (var) getVars ( ) renderCache ( lename, timeStart) render ([action, layout, le]) renderLayout(content, [layout]) set (one, [tset (one, [two])

Controllers Class: plural, camel cased, ends in "Controller" (LineItemsController, PeopleController) plural, underscored (line_items_controller.php, people_controller.php)

Methods
constructClasses() header(status) paginate ([object, scope, whitelist]) disableCache() postConditions(data) redirect(url, [status]) referer([default, local]) render([action, layout, le]) set(one, [two]) setAction (action, [param, param, param]) validate() validateErrors()

Index.php
CAKE_CORE_INCLUDE_PATH ROOT WWW_ROOT WEBROOT_DIR

File:

Paths
APP APP_DIR APP_PATH CACHE CAKE COMPONENTS CONFIGS CONTROLLER_TESTS CONTROLLERS CSS ELEMENTS HELPER_TESTS HELPERS INFLECTIONS JS LAYOUTS LIB_TESTS LIBS LOGS MODEL_TESTS MODELS TESTS TMP VENDORS VIEWS

Helper
$base $here $action $themeWeb $view

Properties
$webroot $params $data $plugin

Views
Path: controller name, underscored (app/views/line_items/<file>, app/views/people/<file>) action name, underscored (index.ctp, view.ctp, admin_index.ctp)

Custom Find Types: all, first, count, list, threaded, neighbors

Callbacks
beforeDelete() afterDelete() beforeFind(query) afterFind(results, primary) beforeValidate() beforeSave() afterSave()

Callbacks
beforeFilter() beforeRender() afterFilter()

File:

Methods
url([url, full]) webroot(file) clean(text) value([field/options, field, key])

Global Functions
config('fileName') debug(message, [escape]) pr(string | array | object) e(message) h(string | array) am(array, [array, array]) cache(path, data, expires, [target]) clearCache([params, type, ext]) env('HTTP_HEADER') __(singular, [return]) __n(singular, plural, count, [return]) __d(domain, msg, [return]) __dn(domain, singular, plural, count, [return]) __dc(domain, msg, category,[return]) __dcn(domain, singular, plural, count,category, [return]) __c(msg, category, [return])

Component
$enabled

Properties
afterRender() beforeLayout() afterLayout()

Callbacks

Callbacks
initialize(&controller) startup(&controller) beforeRender(&controller) beforeRedirect(&controller) shutdown(&controller)

You might also like