CakePHP
Downloads
Latest Release
CakePHP 1.2
Download
|
Tickets
CakePHP 1.3
Download
|
Tickets
CakePHP 2.0
Tickets
Documentation
API
1.1
|
1.2
|
1.3
|
2.0
Book
1.1
|
1.2
|
1.3
|
2.0
Tickets
Translations
Community
Bakery
Contributors
Google Groups
Logo
Planet
Q & A
TV (Screencasts)
Services
Certification
Consultation
Support
Training
Login
Register
English
Arabic (Egypt)
Bulgarian
Chinese
Czech
German (Standard)
Greek
English
Spanish (Spain - Traditional)
Farsi
French (Standard)
Hungarian
Indonesian
Italian
Japanese
Korean
Malaysian
Dutch (Standard)
Portuguese (Portugal)
Polish
Romanian
Russian
Slovak
Turkish
Chinese (Taiwan)
Welcome to the Cookbook
The 1.3 Book
The 1.2 Book
The 1.1 Book
The 2.0 Book
Clear Local Cache
1 Beginning With CakePHP
1.1 What is CakePHP? Why Use it?
1.2 Where to Get Help
1.3 Understanding Model-View-Controller
1.3.1 Benefits
2 Basic Principles of CakePHP
2.1 CakePHP Structure
2.1.1 Controller Extensions ("Components")
2.1.2 View Extensions ("Helpers")
2.1.3 Model Extensions ("Behaviors")
2.1.4 Application Extensions
2.2 A Typical CakePHP Request
2.3 CakePHP Folder Structure
2.3.1 The App Folder
2.4 CakePHP Conventions
2.4.1 File and Classname Conventions
2.4.2 Model and Database Conventions
2.4.3 Controller Conventions
2.4.3.1 URL Considerations for Controller Names
2.4.4 View Conventions
3 Developing with CakePHP
3.1 Requirements
3.2 Installation Preparation
3.2.1 Getting CakePHP
3.2.2 Permissions
3.3 Installation
3.3.1 Development
3.3.2 Production
3.3.3 Advanced Installation
3.3.3.1 Additional Class Paths
3.3.4 Apache and mod_rewrite (and .htaccess)
3.3.5 Pretty URLs and Lighttpd
3.3.6 Pretty URLs on nginx
3.3.7 Fire It Up
3.4 Configuration
3.4.1 Database Configuration
3.4.2 Core Configuration
3.4.3 The Configuration Class
3.4.3.1 Configure Methods
3.4.3.1.1 write
3.4.3.1.2 read
3.4.3.1.3 delete
3.4.3.1.4 load
3.4.3.1.5 version
3.4.3.2 CakePHP Core Configuration Variables
3.4.3.3 Configuration Constants
3.4.4 The App Class
3.4.4.1 Using App::import()
3.4.4.2 Importing Core Libs
3.4.4.3 Importing Controllers, Models, Components, Behaviors, and Helpers
3.4.4.3.1 Loading Controllers
3.4.4.3.2 Loading Models
3.4.4.3.3 Loading Components
3.4.4.3.4 Loading Behaviors
3.4.4.3.5 Loading Helpers
3.4.4.4 Loading from Plugins
3.4.4.5 Loading Vendor Files
3.4.4.5.1 Vendor examples
3.4.5 Routes Configuration
3.4.5.1 Default Routing
3.4.5.2 Named parameters
3.4.5.3 Defining Routes
3.4.5.4 Passing parameters to action
3.4.5.5 Prefix Routing
3.4.5.6 Plugin routing
3.4.5.7 File extensions
3.4.6 Inflections
3.4.7 Bootstrapping CakePHP
3.5 Controllers
3.5.1 Introduction
3.5.2 The App Controller
3.5.3 The Pages Controller
3.5.4 Controller Attributes
3.5.4.1 $name
3.5.4.2 $components, $helpers and $uses
3.5.4.3 Page-related Attributes: $layout and $pageTitle
3.5.4.4 The Parameters Attribute ($params)
3.5.4.4.1 form
3.5.4.4.2 admin
3.5.4.4.3 bare
3.5.4.4.4 isAjax
3.5.4.4.5 controller
3.5.4.4.6 action
3.5.4.4.7 pass
3.5.4.4.8 url
3.5.4.4.9 data
3.5.4.4.10 prefix
3.5.4.4.11 named
3.5.4.5 Other Attributes
3.5.4.6 persistModel
3.5.5 Controller Methods
3.5.5.1 Interacting with Views
3.5.5.1.1 set
3.5.5.1.2 render
3.5.5.2 Flow Control
3.5.5.2.1 redirect
3.5.5.2.2 flash
3.5.5.3 Callbacks
3.5.5.4 Other Useful Methods
3.5.5.4.1 constructClasses
3.5.5.4.2 referer
3.5.5.4.3 disableCache
3.5.5.4.4 postConditions
3.5.5.4.5 paginate
3.5.5.4.6 requestAction
3.5.5.4.7 loadModel
3.6 Components
3.6.1 Introduction
3.6.2 Configuring Components
3.6.3 Component callbacks
3.6.4 Creating Components
3.6.4.1 Including Components in your Controllers
3.6.4.2 MVC Class Access Within Components
3.6.4.3 Using other Components in your Component
3.7 Models
3.7.1 Understanding Models
3.7.2 Creating Database Tables
3.7.2.1 Data Type Associations by Database
3.7.2.1.1 MySQL
3.7.2.1.2 MySQLi
3.7.2.1.3 ADOdb
3.7.2.1.4 DB2
3.7.2.1.5 Firebird/Interbase
3.7.2.1.6 MS SQL
3.7.2.1.7 Oracle
3.7.2.1.8 PostgreSQL
3.7.2.1.9 SQLite
3.7.2.1.10 Sybase
3.7.2.2 Titles
3.7.2.3 created and modified
3.7.2.4 Using UUIDs as Primary Keys
3.7.3 Retrieving Your Data
3.7.3.1 find
3.7.3.1.1 find('first')
3.7.3.1.2 find('count')
3.7.3.1.3 find('all')
3.7.3.1.4 find('list')
3.7.3.1.5 find('threaded')
3.7.3.1.6 find('neighbors')
3.7.3.2 findAllBy
3.7.3.3 findBy
3.7.3.4 query
3.7.3.5 field
3.7.3.6 read()
3.7.3.7 Complex Find Conditions
3.7.4 Saving Your Data
3.7.4.1 Saving Related Model Data (hasOne, hasMany, belongsTo)
3.7.4.1.1 counterCache - Cache your count()
3.7.4.2 Saving Related Model Data (HABTM)
3.7.5 Deleting Data
3.7.5.1 delete
3.7.5.2 remove
3.7.5.3 deleteAll
3.7.6 Associations: Linking Models Together
3.7.6.1 Relationship Types
3.7.6.2 hasOne
3.7.6.3 belongsTo
3.7.6.4 hasMany
3.7.6.5 hasAndBelongsToMany (HABTM)
3.7.6.6 Creating and Destroying Associations on the Fly
3.7.6.7 Multiple relations to the same model
3.7.6.8 Joining tables
3.7.7 Callback Methods
3.7.7.1 beforeFind
3.7.7.2 afterFind
3.7.7.3 beforeValidate
3.7.7.4 beforeSave
3.7.7.5 afterSave
3.7.7.6 beforeDelete
3.7.7.7 afterDelete
3.7.7.8 onError
3.7.8 Model Attributes
3.7.8.1 useDbConfig
3.7.8.2 useTable
3.7.8.3 tablePrefix
3.7.8.4 primaryKey
3.7.8.5 displayField
3.7.8.6 recursive
3.7.8.7 order
3.7.8.8 data
3.7.8.9 _schema
3.7.8.10 validate
3.7.8.11 name
3.7.8.12 cacheQueries
3.7.9 Additional Methods and Properties
3.8 Behaviors
3.8.1 Using Behaviors
3.8.2 Creating Behaviors
3.8.3 Creating behavior methods
3.9 DataSources
3.9.1 Basic API For DataSources
3.9.2 An Example
3.10 Views
3.10.1 View Templates
3.10.2 Layouts
3.10.3 Elements
3.10.3.1 Passing Variables into an Element
3.10.3.2 Caching Elements
3.10.3.3 Requesting Elements from a Plugin
3.10.4 View methods
3.10.4.1 set()
3.10.4.2 getVar()
3.10.4.3 getVars()
3.10.4.4 error()
3.10.4.5 element()
3.10.4.6 uuid()
3.10.4.7 addScript()
3.10.5 Themes
3.10.6 Media Views
3.11 Helpers
3.11.1 Using Helpers
3.11.2 Creating Helpers
3.11.2.1 Including other Helpers
3.11.2.2 Callback method
3.11.2.3 Using your Helper
3.11.3 Creating Functionality for All Helpers
3.11.4 Core Helpers
3.12 Scaffolding
3.12.1 Creating a simple admin interface with scaffolding
3.12.2 Customizing Scaffold Views
3.13 The CakePHP Console
3.13.1 Creating Shells & Tasks
3.13.1.1 Creating Your Own Shells
3.13.1.2 Tasks
3.13.2 Running Shells as cronjobs
3.14 Plugins
3.14.1 Creating a Plugin
3.14.2 Plugin Controllers
3.14.3 Plugin Models
3.14.4 Plugin Views
3.14.5 Components, Helpers and Behaviors
3.14.6 Plugin Images, CSS and Javascript
3.14.7 Plugin Tips
3.15 Global Constants and Functions
3.15.1 Global Functions
3.15.1.1 __
3.15.1.2 a
3.15.1.3 aa
3.15.1.4 am
3.15.1.5 config
3.15.1.6 convertSlash
3.15.1.7 countdim
3.15.1.8 debug
3.15.1.9 e
3.15.1.10 env
3.15.1.11 fileExistsInPath
3.15.1.12 h
3.15.1.13 ife
3.15.1.14 low
3.15.1.15 paths
3.15.1.16 pr
3.15.1.17 r
3.15.1.18 stripslashes_deep
3.15.1.19 up
3.15.1.20 uses
3.15.2 Core Definition Constants
4 Common Tasks With CakePHP
4.1 Data Validation
4.1.1 Simple Rules
4.1.2 One Rule Per Field
4.1.2.1 rule
4.1.2.2 required
4.1.2.3 allowEmpty
4.1.2.4 on
4.1.2.5 message
4.1.2.6 last
4.1.3 Multiple Rules per Field
4.1.4 Core Validation Rules
4.1.4.1 alphaNumeric
4.1.4.2 between
4.1.4.3 blank
4.1.4.4 boolean
4.1.4.5 cc
4.1.4.6 comparison
4.1.4.7 date
4.1.4.8 decimal
4.1.4.9 email
4.1.4.10 equalTo
4.1.4.11 extension
4.1.4.12 file
4.1.4.13 ip
4.1.4.14 isUnique
4.1.4.15 minLength
4.1.4.16 maxLength
4.1.4.17 money
4.1.4.18 multiple
4.1.4.19 inList
4.1.4.20 numeric
4.1.4.21 notEmpty
4.1.4.22 phone
4.1.4.23 postal
4.1.4.24 range
4.1.4.25 ssn
4.1.4.26 url
4.1.5 Custom Validation Rules
4.1.5.1 Custom Regular Expression Validation
4.1.5.2 Adding your own Validation Methods
4.1.6 Validating Data from the Controller
4.2 Data Sanitization
4.2.1 paranoid
4.2.2 html
4.2.3 escape
4.2.4 clean
4.3 Error Handling
4.4 Debugging
4.4.1 Basic Debugging
4.4.2 Using the Debugger Class
4.4.3 Debugger Class
4.5 Caching
4.6 Logging
4.6.1 Using the log function
4.7 Testing
4.7.1 Preparing for testing
4.7.1.1 Installing SimpleTest
4.7.1.2 Running Core test cases
4.7.2 Testing overview - Unit testing vs. Web testing
4.7.3 Preparing test data
4.7.3.1 About fixtures
4.7.3.2 Creating fixtures
4.7.3.3 Importing table information and records
4.7.4 Creating tests
4.7.4.1 CakeTestCase Callback Methods
4.7.5 Testing models
4.7.5.1 Creating a test case
4.7.5.2 Creating a test method
4.7.6 Testing controllers
4.7.6.1 Creating a test case
4.7.6.2 The testAction method
4.7.6.3 Pitfalls
4.7.7 Testing Helpers
4.7.7.1 Creating Helper test, part I
4.7.8 Testing components
4.7.8.1 Initializing the component
4.7.8.2 Creating a test method
4.7.9 Web testing - Testing views
4.7.9.1 About CakeWebTestCase
4.7.9.2 Creating a test
4.7.9.3 Walking through a page
4.7.10 Testing plugins
4.7.11 Miscellaneous
4.7.11.1 Customizing the test reporter
4.7.11.2 Grouping tests
4.7.12 Running tests in the Command Line
4.8 Internationalization & Localization
4.8.1 Internationalizing Your Application
4.8.2 Localization in CakePHP
4.9 Pagination
4.9.1 Controller Setup
4.9.2 Pagination in Views
4.9.3 AJAX Pagination
4.9.3.1 Layout Changes
4.9.3.2 View Changes
4.9.4 Custom Query Pagination
4.10 REST
4.10.1 The Simple Setup
4.10.2 Custom REST Routing
5 Core Components
5.1 Access Control Lists
5.1.1 Understanding How ACL Works
5.1.2 Defining Permissions: Cake's INI-based ACL
5.1.3 Defining Permissions: Cake's Database ACL
5.1.3.1 Getting Started
5.1.3.2 Creating Access Request Objects (AROs) and Access Control Objects (ACOs)
5.1.3.3 Assigning Permissions
5.1.3.4 Checking Permissions: The ACL Component
5.2 Authentication
5.2.1 Setting Auth Component Variables
5.2.2 Displaying Auth Error Messages
5.2.3 Troubleshooting Auth Problems
5.2.4 Change Hash Function
5.2.5 AuthComponent Methods
5.2.5.1 action
5.2.5.2 allow
5.2.5.3 deny
5.2.5.4 hashPasswords
5.2.5.5 mapActions
5.2.5.6 login
5.2.5.7 logout
5.2.5.8 password
5.2.5.9 user
5.2.6 AuthComponent Variables
5.2.6.1 userModel
5.2.6.2 fields
5.2.6.3 userScope
5.2.6.4 loginAction
5.2.6.5 loginRedirect
5.2.6.6 logoutRedirect
5.2.6.7 loginError
5.2.6.8 authError
5.2.6.9 autoRedirect
5.2.6.10 authorize
5.2.6.11 sessionKey
5.2.6.12 ajaxLogin
5.2.6.13 authenticate
5.2.6.14 actionPath
5.3 Cookies
5.3.1 Controller Setup
5.3.2 Using the Component
5.4 Email
5.4.1 Class Attributes and Variables
5.4.1.1 Sending Multiple Emails in a loop
5.4.2 Sending a basic message
5.4.2.1 Setting up the Layouts
5.4.2.2 Setup an email element for the message body
5.4.2.3 Controller
5.4.3 Sending A Message Using SMTP
5.5 Request Handling
5.5.1 Obtaining Request Information
5.5.2 Request Type Detection
5.5.3 Obtaining Additional Client Information
5.5.4 Responding To Requests
5.6 Security Component
5.6.1 Configuration
5.6.2 Methods
5.6.2.1 requirePost()
5.6.2.2 requireSecure()
5.6.2.3 requireAuth()
5.6.2.4 requireLogin()
5.6.2.5 loginCredentials(string $type)
5.6.2.6 loginRequest(array $options)
5.6.2.7 parseDigestAuthData(string $digest)
5.6.2.8 generateDigestResponseHash(array $data)
5.6.2.9 blackHole(object $controller, string $error)
5.6.3 Usage
5.6.4 Basic HTTP Authentication
5.7 Sessions
5.7.1 Methods
5.7.1.1 write
5.7.1.2 setFlash
5.7.1.3 read
5.7.1.4 check
5.7.1.5 delete
5.7.1.6 destroy
5.7.1.7 error
6 Core Behaviors
6.1 ACL
6.1.1 Using the AclBehavior
6.1.2 node()
6.2 Containable
6.3 Translate
6.3.1 Initializing the i18n Database Tables
6.3.2 Attaching the Translate Behavior to your Models
6.3.3 Defining the Fields
6.3.4 Conclusion
6.3.5 Retrieve all translation records for a field
6.3.5.1 Using the bindTranslation method
6.3.6 Saving in another language
6.3.7 Multiple Translation Tables
6.3.7.1 Create the TranslateModel
6.3.7.2 Changing the Table
6.4 Tree
6.4.1 Requirements
6.4.2 Basic Usage
6.4.2.1 Adding data
6.4.2.2 Modifying data
6.4.2.3 Deleting data
6.4.2.4 Querying and using your data
6.4.2.4.1 Children
6.4.2.4.2 Counting children
6.4.2.4.3 generatetreelist
6.4.2.4.4 getparentnode
6.4.2.4.5 getpath
6.4.3 Advanced Usage
6.4.3.1 moveDown
6.4.3.2 moveUp
6.4.3.3 removeFromTree
6.4.3.4 reorder
6.4.4 Data Integrity
7 Core Helpers
7.1 AJAX
7.1.1 AjaxHelper Options
7.1.1.1 General Options
7.1.1.2 Callback Options
7.1.2 Methods
7.1.2.1 link
7.1.2.2 remoteFunction
7.1.2.3 remoteTimer
7.1.2.4 form
7.1.2.5 submit
7.1.2.6 observeField
7.1.2.7 observeForm
7.1.2.8 autoComplete
7.1.2.9 isAjax
7.1.2.10 drag & drop
7.1.2.11 slider
7.1.2.12 editor
7.1.2.13 sortable
7.2 Cache
7.2.1 General Caching
7.2.2 Cache Engines in Cake
7.2.3 Cache Helper Configuration
7.2.4 Caching in the Controller
7.2.5 Marking Non-Cached Content in Views
7.2.6 Clearing the Cache
7.3 Form
7.3.1 Creating Forms
7.3.1.1 $options[‘type’]
7.3.1.2 $options[‘action’]
7.3.1.3 $options[‘url’]
7.3.1.4 $options[‘default’]
7.3.2 Closing the Form
7.3.3 Automagic Form Elements
7.3.3.1 Field naming convention
7.3.3.2 $options[‘type’]
7.3.3.3 $options[‘before’], $options[‘between’], $options[‘separator’] and $options[‘after’]
7.3.3.4 $options[‘options’]
7.3.3.5 $options[‘multiple’]
7.3.3.6 $options[‘maxLength’]
7.3.3.7 $options[‘div’]
7.3.3.8 $options[‘label’]
7.3.3.9 $options['legend']
7.3.3.10 $options[‘id’]
7.3.3.11 $options['error']
7.3.3.12 $options['default']
7.3.3.13 $options[‘selected’]
7.3.3.14 $options[‘rows’], $options[‘cols’]
7.3.3.15 $options[‘empty’]
7.3.3.16 $options[‘timeFormat’]
7.3.3.17 $options[‘dateFormat’]
7.3.3.18 $options['minYear'], $options['maxYear']
7.3.3.19 $options['interval']
7.3.3.20 $options['class']
7.3.4 File Fields
7.3.4.1 Validating Uploads
7.3.5 Form Element-Specific Methods
7.3.5.1 checkbox
7.3.5.2 button
7.3.5.3 year
7.3.5.4 month
7.3.5.5 dateTime
7.3.5.6 day
7.3.5.7 hour
7.3.5.8 minute
7.3.5.9 meridian
7.3.5.10 error
7.3.5.11 file
7.3.5.12 hidden
7.3.5.13 isFieldError
7.3.5.14 label
7.3.5.15 password
7.3.5.16 radio
7.3.5.17 select
7.3.5.18 submit
7.3.5.19 text
7.3.5.20 textarea
7.4 HTML
7.4.1 Inserting Well-Formatted elements
7.4.1.1 charset
7.4.1.2 css
7.4.1.3 meta
7.4.1.4 docType
7.4.1.5 style
7.4.1.6 image
7.4.1.7 link
7.4.1.8 tag
7.4.1.9 div
7.4.1.10 para
7.4.1.11 tableHeaders
7.4.1.12 tableCells
7.4.1.13 url
7.4.2 Changing the tags output by HtmlHelper
7.5 Javascript
7.5.1 Methods
7.6 Number
7.6.1 currency
7.6.2 precision
7.6.3 toPercentage
7.6.4 toReadableSize
7.6.5 format
7.7 Paginator
7.7.1 Methods
7.8 RSS
7.8.1 Creating an RSS feed with the RssHelper
7.8.1.1 Controller Code
7.8.1.1.1 Layout
7.8.1.1.2 View
7.9 Session
7.9.1 Methods
7.9.2 flash
7.9.2.1 Using Flash for Success and Failure
7.10 Text
7.11 Time
7.11.1 Formatting
7.11.2 Testing Time
7.12 XML
7.12.1 serialize
7.12.2 elem
7.12.3 header
8 Core Utility Libraries
8.1 App
8.2 Inflector
8.2.1 Class methods
8.3 String
8.3.1 uuid
8.3.2 tokenize
8.3.3 insert
8.3.4 cleanInsert
8.4 Xml
8.4.1 Xml parsing
8.5 Set
8.5.1 Set-compatible Path syntax
8.5.2 insert
8.5.3 sort
8.5.4 reverse
8.5.5 combine
8.5.6 normalize
8.5.7 countDim
8.5.8 isEqual
8.5.9 diff
8.5.10 check
8.5.11 remove
8.5.12 classicExtract
8.5.13 matches
8.5.14 extract
8.5.15 format
8.5.16 enum
8.5.17 numeric
8.5.18 map
8.5.19 pushDiff
8.5.20 filter
8.5.21 merge
8.5.22 contains
8.6 Security
8.7 Cache
8.7.1 Cache::read()
8.7.2 Cache::write()
8.7.3 Cache::delete()
8.7.4 Cache::config()
8.7.5 Cache::set()
8.8 HttpSocket
8.8.1 get
8.8.2 post
8.8.3 request
9 Core Console Applications
9.1 Code Generation with Bake
9.2 Schema management and migrations
9.2.1 Generating and using Schema files
9.2.2 Migrations with CakePHP schema shell
9.3 Modify default HTML produced by "baked" templates
10 Tutorials & Examples
10.1 Blog
10.1.1 Getting Cake
10.1.2 Creating the Blog Database
10.1.3 Cake Database Configuration
10.1.4 Optional Configuration
10.1.5 A Note on mod_rewrite
10.1.6 Create a Post Model
10.1.7 Create a Posts Controller
10.1.8 Creating Post Views
10.1.9 Adding Posts
10.1.10 Data Validation
10.1.11 Deleting Posts
10.1.12 Editing Posts
10.1.13 Routes
10.1.14 Conclusion
10.2 Simple Acl controlled Application
10.2.1 Preparing our Application
10.2.2 Preparing to Add Auth
10.2.3 Initialize the Db Acl tables
10.2.4 Acts As a Requester
10.2.5 Creating ACOs
10.2.6 An Automated tool for creating ACOs
10.2.7 Setting up permissions
10.2.8 Logging in
10.2.9 Logout
10.2.10 All done
11 Appendices
11.1 Migrating from CakePHP 1.1 to 1.2
11.1.1 Configure
11.1.2 HTML Helper to Form Helper
11.1.3 Loading Files
11.1.4 Model::generateList()
11.1.5 Possible Migration Approach
3 Developing with CakePHP
Edit
Comments (0)
History
Now you’re cooking.
« View Conventions
|
Requirements »