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.3版本
CakePHP 手册
1 开始CakePHP之旅
1.1 什么是CakePHP? 为什么使用它?
1.2 从哪里可以获得帮助
1.3 理解MVC(Model-View-Controller)模式-视图-控制器
2 CakePHP的基本原则
2.1 CakePHP的结构
2.1.1 控制器扩展──组件(Component)
2.1.2 视图扩展──助手(Helper)
2.1.3 模型扩展──行为(Behavior)
2.1.4 应用扩展 Application Extensions
2.2 一次典型的CakePHP请求
2.3 CakePHP 档案结构
2.4 CakePHP命名规则
2.4.1 文件及类名称命名规则
2.4.2 模型及数据库命名规则
2.4.3 控制器命名規則
2.4.3.1 关于控制器的地址的命名考虑
2.4.4 视图文件的命名习惯
3 使用CakePHP进行开发
3.1 必要条件
3.2 准备安装
3.2.1 获取 CakePHP
3.2.2 权限
3.3 安装
3.3.1 开发模式安装
3.3.2 产品环境安装
3.3.3 高级安装
3.3.3.1 附加类的路径(Additional Class Paths)
3.3.4 Apache 和 mod_rewrite
3.3.5 Lighttpd 和 mod_magnet
3.3.6 Pretty URLs on nginx
3.3.7 URL Rewrites on IIS7 (Windows hosts)
3.3.8 开火
3.4 配置
3.4.1 数据库配置
3.4.2 全局配置
3.4.3 配置类
3.4.3.1 配置函数
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 内核配置变量
3.4.3.3 Configuration Constants
3.4.4 App类
3.4.4.1 App::import()方法的使用
3.4.4.2 导入核心库
3.4.4.3 导入控制器(Controllers),模块(Models),组件(Components),行为(Behaviors)和助手(Helpers)
3.4.4.3.1 加载控制器(Controllers)
3.4.4.3.2 加载模块(Models)
3.4.4.3.3 加载组件(Components)
3.4.4.3.4 加载行为(Behaviors)
3.4.4.3.5 加载助手(Helpers)
3.4.4.3.6 加载助手(Helpers)
3.4.4.4 导入插件(Plugins)
3.4.4.5 加载Vendor文件
3.4.4.5.1 加载Vendor的例子
3.4.5 路由配置
3.4.5.1 默认路由 Routing
3.4.5.2 Passed arguments
3.4.5.3 Named parameters
3.4.5.4 定义路由
3.4.5.5 向动作(action)传递参数
3.4.5.6 前缀路由
3.4.5.7 Plugin routing
3.4.5.8 File extensions 文件扩展
3.4.5.9 Custom Route classes
3.4.6 自定义Inflections
3.4.7 配置bootstrap文件
3.5 控制器(Controllers)
3.5.1 控制器基类
3.5.2 页面控制器
3.5.3 控制器属性
3.5.3.1 $name
3.5.3.2 $components, $helpers, $uses
3.5.3.3 与页面相关的属性: $layout,$pageTitle
3.5.3.4 参数属性 ($params)
3.5.3.4.1 form表单
3.5.3.4.2 admin
3.5.3.4.3 bare
3.5.3.4.4 isAjax
3.5.3.4.5 controller
3.5.3.4.6 action
3.5.3.4.7 pass
3.5.3.4.8 url
3.5.3.4.9 data
3.5.3.4.10 prefix
3.5.3.4.11 named
3.5.3.5 其他属性
3.5.3.6 persistModel
3.5.4 控制器方法
3.5.4.1 与视图进行交互
3.5.4.2 流程控制
3.5.4.2.1 重定向(redirect)
3.5.4.2.2 flash
3.5.4.3 Callbacks
3.5.4.4 其他有用的方法
3.5.4.4.1 constructClasses
3.5.4.4.2 referer
3.5.4.4.3 disableCache
3.5.4.4.4 postConditions
3.5.4.4.5 paginate
3.5.4.4.6 requestAction
3.5.4.4.7 loadModel
3.6 组件(Components)
3.6.1 简介
3.6.2 配置组件
3.6.3 自定义组件
3.6.3.1 在控制器中引用组件
3.6.3.2 在组件中访问MVC
3.6.3.3 在组件中使用其它组件
3.7 模型(Models)
3.7.1 理解模型
3.7.2 创建数据表
3.7.2.1 数据类型映射
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 标题名
3.7.2.3 created 和 modified
3.7.2.4 使用UUID作为主键
3.7.3 获取数据
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 复杂条件查询
3.7.4 保存数据
3.7.4.1 向关联模型中保存数据 (hasOne, hasMany, belongsTo)
3.7.4.1.1 counterCache - 缓存count()结果
3.7.4.2 向关联模型中保存数据 (HABTM)
3.7.5 删除数据
3.7.5.1 del
3.7.5.2 deleteAll
3.7.6 关联:将模型串在一起
3.7.6.1 关联类型
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 hasMany through (The Join Model)
3.7.6.7 Creating and Destroying Associations on the Fly
3.7.6.8 Multiple relations to the same model
3.7.6.9 Joining tables
3.7.7 回调方法
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 模型属性
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 virtualFields
3.7.8.12 name
3.7.8.13 cacheQueries
3.7.9 自定义方法与属性
3.7.9.1 Using virtualFields
3.7.10 Virtual fields
3.7.10.1 Creating virtual fields
3.7.10.2 Using virtual fields
3.7.10.3 Virtual fields and model aliases
3.7.10.4 Limitations of virtualFields
3.7.11 Transactions
3.8 行为(Behaviors)
3.8.1 使用行为(Behavior)
3.8.2 创建自定义行为(Behavior)
3.8.3 Creating behavior methods
3.8.4 Behavior callbacks
3.8.5 Creating a behavior callback
3.9 数据源
3.9.1 数据源的基本接口(Basic API For DataSources)
3.9.2 An Example
3.9.3 Plugin DataSources and Datasource Drivers
3.10 视图(View)
3.10.1 视图模板
3.10.2 布局[Layouts]
3.10.3 元素[Elements]
3.10.3.1 向元素传递参数
3.10.3.2 缓存元素
3.10.3.3 从插件中显示元素
3.10.4 视图方法
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 主题
3.10.5.1 Increasing performance of plugin and theme assets
3.10.6 媒体视图
3.11 助手(Helper)
3.11.1 使用助手(helpers)
3.11.2 创建助手(Helpers)
3.11.2.1 使用其他的Helper
3.11.2.2 Callback method
3.11.2.3 使用创建好的助手
3.11.3 创建所有助手使用的功能(Creating Functionality for All Helpers)
3.11.4 内核助手(Core Helpers)
3.12 脚手架(Scaffolding)
3.12.1 使用脚手架(Scaffolding)创建一个简单的后台管理界面
3.12.2 自定义脚手架视图
3.13 CakePHP控制台
3.13.1 创建脚本(Shell)和任务(Task)
3.13.1.1 创建你自己的Shells
3.13.1.2 Tasks
3.13.2 Running Shells as cronjobs
3.14 插件(Plugins)
3.14.1 创建插件
3.14.2 插件控制器
3.14.3 插件模型
3.14.4 插件的视图
3.14.5 组件,助手,行为
3.14.6 插件中的CSS和Javascript
3.14.7 插件的一些诀窍
3.15 全局常量和函数
3.15.1 全局函数
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 debug
3.15.1.8 e
3.15.1.9 env
3.15.1.10 fileExistsInPath
3.15.1.11 h
3.15.1.12 ife
3.15.1.13 low
3.15.1.14 pr
3.15.1.15 r
3.15.1.16 stripslashes_deep
3.15.1.17 up
3.15.1.18 uses
3.15.2 核心常量定义
3.16 Vendor packages
3.16.1 Vendor assets
4 CakePHP常用功能
4.1 数据校验
4.1.1 简单规则
4.1.2 每个字段一个规则
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.3 单字段多规则
4.1.4 核心校验规则
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 自定义校验规则
4.1.5.1 自定义正则表达式
4.1.5.2 添加自己的校验方法
4.1.6 在控制器中校验数据
4.2 数据清理
4.2.1 paranoid
4.2.2 html
4.2.3 escape
4.2.4 clean
4.3 错误处理
4.4 调试
4.4.1 基础调试
4.4.2 使用Debugger类
4.4.3 Debugger类
4.5 缓存
4.6 日志
4.6.1 使用日志记录函数
4.6.2 使用FileLog类
4.6.3 Creating and configuring log streams
4.6.4 Interacting with log streams
4.6.5 Error logging
4.7 测试
4.7.1 测试前的准备
4.7.1.1 安装简单测试包(SimpleTest)
4.7.1.2 执行核心测试用例
4.7.2 测试概览 - 单元测试(Unit testing)与站点测试(Web testing)
4.7.3 准备测试数据
4.7.3.1 关于测试模板
4.7.3.2 创建测试模板
4.7.3.3 导入表和数据
4.7.4 创建测试
4.7.4.1 CakeTestCase 的回调函数
4.7.5 对模块的测试
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 Test Reporter methods
4.7.11.3 Grouping tests
4.7.12 Running tests in the Command Line
4.7.13 Test Suite changes in 1.3
4.8 本地化和国际化 - Localization & Internationalization
4.8.1 本地化你的Application
4.8.2 Localization in CakePHP
4.9 分页(Pagination)
4.9.1 控制器设置
4.9.2 视图中使用分页
4.9.3 AJAX Pagination
4.9.4 Custom Query Pagination
4.10 REST
4.10.1 简单配置
4.10.2 自定义REST路由
5 核心组件
5.1 访问控制列表(ACL)
5.1.1 理解ACL如何工作
5.1.2 定义权限:基于INI文件的ACL
5.1.3 定义权限:基于数据库的ACL
5.1.3.1 开始
5.1.3.2 创建请求访问对象(AROs)和访问控制对象(ACOs)
5.1.3.3 分配权限
5.1.3.4 检查权限:使用ACL组件
5.2 认证(Authentication)
5.2.1 设置 Auth 组件变量
5.2.2 显示 Auth 错误信息
5.2.3 Auth 疑难解决
5.2.3.1 Password Hashing
5.2.4 改变散列(Hash)函数
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 Auth组件变量
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.2.6.15 flashElement
5.2.7 allowedActions
5.3 Cookies
5.3.1 Controller Setup
5.3.2 Using the Component
5.4 Email
5.4.1 邮件类属性和变量设定
5.4.1.1 循环发送多封邮件
5.4.1.2 Debugging Emails
5.4.2 发送一封简单的邮件
5.4.2.1 设定布局
5.4.2.2 设置一个电子邮件的邮件正文内容
5.4.2.3 使用email的控制器 代码
5.4.2.4 Attachments
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 方法
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 核心行为(Behavior)
6.1 ACL
6.1.1 Using the AclBehavior
6.1.2 node()
6.2 Containable
6.2.1 Using Containable with pagination
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 前提
6.4.2 基本用法
6.4.2.1 添加数据
6.4.2.2 修改数据
6.4.2.3 删除数据
6.4.2.4 查询以及使用数据
6.4.2.4.1 Children
6.4.2.4.2 子节点计数
6.4.2.4.3 generatetreelist
6.4.2.4.4 getparentnode
6.4.2.4.5 getpath
6.4.3 高级用法
6.4.3.1 moveDown
6.4.3.2 moveUp
6.4.3.3 removeFromTree
6.4.3.4 reorder
6.4.4 数据完整性
6.4.4.1 Recover
6.4.4.2 Reorder
6.4.4.3 Verify
7 核心助手(Helper)
7.1 AJAX
7.1.1 AjaxHelper 选项
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 创建表单
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.1.5 $options['inputDefaults']
7.3.2 关闭表单
7.3.3 表单元素
7.3.3.1 字段命名规则
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.3.21 $options['hiddenField']
7.3.4 File元素
7.3.4.1 对上传文件进行校验
7.3.5 表单元素-特定方法
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.3.6 1.3 improvements
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 script
7.4.1.12 scriptBlock
7.4.1.13 scriptStart
7.4.1.14 scriptEnd
7.4.1.15 tableHeaders
7.4.1.16 tableCells
7.4.1.17 url
7.4.2 Changing the tags output by HtmlHelper
7.4.3 Creating breadcrumb trails with HtmlHelper
7.5 Js
7.5.1 Using a specific Javascript engine
7.5.1.1 Using the JsHelper inside customHelpers
7.5.2 Creating a Javascript Engine
7.5.3 Javascript engine usage
7.5.3.1 Working with buffered scripts
7.5.4 Methods
7.5.5 Ajax Pagination
7.5.5.1 Making Ajax Links
7.6 Javascript
7.6.1 Methods
7.7 Number
7.7.1 currency
7.7.2 precision
7.7.3 toPercentage
7.7.4 toReadableSize
7.7.5 format
7.8 Paginator
7.8.1 Methods
7.9 RSS
7.9.1 Creating an RSS feed with the RssHelper
7.9.1.1 Controller Code
7.9.1.1.1 Layout
7.9.1.1.2 View
7.10 Session
7.10.1 Methods
7.10.2 flash
7.11 Text
7.12 Time
7.12.1 Formatting
7.12.2 Testing Time
7.13 XML
7.13.1 serialize
7.13.2 elem
7.13.3 header
8 核心工具库
8.1 App
8.2 Inflector
8.2.1 方法示例
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 的解析
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 diff
8.5.9 check
8.5.10 remove
8.5.11 classicExtract
8.5.12 matches
8.5.13 extract
8.5.14 format
8.5.15 enum
8.5.16 numeric
8.5.17 map
8.5.18 pushDiff
8.5.19 filter
8.5.20 merge
8.5.21 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
8.9 Router
9 核心控制台应用程序
9.1 Code Generation with Bake
9.1.1 Bake improvements in 1.3
9.2 计划管理和迁移
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 Deployment
11 应用程序举例
11.1 一个博客的小例子
11.1.1 获取 Cake
11.1.2 创建博客数据库
11.1.3 数据库的配置
11.1.4 Optional Configuration
11.1.5 A Note on mod_rewrite
11.1.6 新建一个Post模型(Model)
11.1.7 建立一个 Posts 控制器
11.1.8 创建一个Post视图
11.1.9 添加帖子
11.1.10 Data Validation
11.1.11 删除 posts
11.1.12 编辑 Posts
11.1.13 Routes
11.1.14 Conclusion
11.2 ACL应用的简单示例
11.2.1 准备
11.2.2 Preparing to Add Auth
11.2.3 Initialize the Db Acl tables
11.2.4 Acts As a Requester
11.2.5 Creating ACOs (Access Control Objects)
11.2.6 An Automated tool for creating ACOs
11.2.7 Setting up permissions
11.2.8 Logging in
11.2.9 Logout
11.2.10 All done
12 附录
12.1 Migrating from CakePHP 1.2 to 1.3
12.2 New features in CakePHP 1.3
1.2版本
CakePHP 手册
1 开始CakePHP之旅
1.1 什么是CakePHP? 为什么使用它?
1.2 从哪里可以获得帮助
1.3 理解MVC(Model-View-Controller)模式-视图-控制器
1.3.1 好处
2 CakePHP的基本原则
2.1 CakePHP的结构
2.1.1 控制器扩展──组件(Component)
2.1.2 视图扩展──助手(Helper)
2.1.3 模型扩展──行为(Behavior)
2.1.4 应用扩展 Application Extensions
2.2 一次典型的CakePHP请求
2.3 CakePHP 档案结构
2.3.1 App资料夹
2.4 CakePHP命名规则
2.4.1 文件及类名称命名规则
2.4.2 模型及数据库命名规则
2.4.3 控制器命名規則
2.4.3.1 关于控制器的地址的命名考虑
2.4.4 视图文件的命名习惯
3 使用CakePHP进行开发
3.1 必要条件
3.2 准备安装
3.2.1 获取 CakePHP
3.2.2 权限
3.3 安装
3.3.1 开发模式安装
3.3.2 产品环境安装
3.3.3 高级安装
3.3.3.1 附加类的路径(Additional Class Paths)
3.3.4 Apache 和 mod_rewrite
3.3.5 Lighttpd 和 mod_magnet
3.3.6 Pretty URLs on nginx
3.3.7 开火
3.4 配置
3.4.1 数据库配置
3.4.2 全局配置
3.4.3 配置类
3.4.3.1 配置函数
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 内核配置变量
3.4.3.3 Configuration Constants
3.4.4 App类
3.4.4.1 App::import()方法的使用
3.4.4.2 导入核心库
3.4.4.3 导入控制器(Controllers),模块(Models),组件(Components),行为(Behaviors)和助手(Helpers)
3.4.4.3.1 加载控制器(Controllers)
3.4.4.3.2 加载模块(Models)
3.4.4.3.3 加载组件(Components)
3.4.4.3.4 加载行为(Behaviors)
3.4.4.3.5 加载助手(Helpers)
3.4.4.4 导入插件(Plugins)
3.4.4.5 加载Vendor文件
3.4.4.5.1 加载Vendor的例子
3.4.5 路由配置
3.4.5.1 默认路由 Routing
3.4.5.2 Named parameters
3.4.5.3 定义路由
3.4.5.4 向动作(action)传递参数
3.4.5.5 前缀路由
3.4.5.6 插件路由
3.4.5.7 File extensions 文件扩展
3.4.6 自定义Inflections
3.4.7 配置bootstrap文件
3.5 控制器(Controllers)
3.5.1 简介
3.5.2 控制器基类
3.5.3 页面控制器
3.5.4 控制器属性
3.5.4.1 $name
3.5.4.2 $components, $helpers, $uses
3.5.4.3 与页面相关的属性: $layout,$pageTitle
3.5.4.4 参数属性 ($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 其他属性
3.5.4.6 persistModel
3.5.5 控制器方法
3.5.5.1 与视图进行交互
3.5.5.1.1 set
3.5.5.1.2 render
3.5.5.2 流程控制
3.5.5.2.1 重定向(redirect)
3.5.5.2.2 flash
3.5.5.3 Callbacks
3.5.5.4 其他有用的方法
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 简介
3.6.2 配置组件
3.6.3 Component callbacks
3.6.4 自定义组件
3.6.4.1 在控制器中引用组件
3.6.4.2 在组件中访问MVC
3.6.4.3 在组件中使用其它组件
3.7 模型(Models)
3.7.1 理解模型
3.7.2 创建数据表
3.7.2.1 数据类型映射
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 标题名
3.7.2.3 created 和 modified
3.7.2.4 使用UUID作为主键
3.7.3 获取数据
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 复杂条件查询
3.7.4 保存数据
3.7.4.1 向关联模型中保存数据 (hasOne, hasMany, belongsTo)
3.7.4.1.1 counterCache - 缓存count()结果
3.7.4.2 向关联模型中保存数据 (HABTM)
3.7.5 删除数据
3.7.5.1 del
3.7.5.2 remove
3.7.5.3 deleteAll
3.7.6 关联:将模型串在一起
3.7.6.1 关联类型
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 回调方法
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 模型属性
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 自定义方法与属性
3.8 行为(Behaviors)
3.8.1 使用行为(Behavior)
3.8.2 创建自定义行为(Behavior)
3.8.3 Creating behavior methods
3.9 DataSources
3.9.1 数据源的基本接口(Basic API For DataSources)
3.9.2 An Example
3.10 视图(View)
3.10.1 视图模板
3.10.2 布局[Layouts]
3.10.3 元素[Elements]
3.10.3.1 向元素传递参数
3.10.3.2 缓存元素
3.10.3.3 从插件中显示元素
3.10.4 视图方法
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 主题
3.10.6 媒体视图
3.11 助手(Helper)
3.11.1 使用助手(helpers)
3.11.2 创建助手(Helpers)
3.11.2.1 使用其他的Helper
3.11.2.2 Callback method
3.11.2.3 使用创建好的助手
3.11.3 创建所有助手使用的功能(Creating Functionality for All Helpers)
3.11.4 内核助手(Core Helpers)
3.12 脚手架(Scaffolding)
3.12.1 使用脚手架(scaffolding)创建一个简单的管理界面
3.12.2 自定义脚手架视图
3.13 CakePHP控制台
3.13.1 创建脚本(Shell)和任务(Task)
3.13.1.1 创建你自己的Shells
3.13.1.2 Tasks
3.13.2 Running Shells as cronjobs
3.14 插件(Plugins)
3.14.1 创建插件
3.14.2 插件控制器
3.14.3 插件模型
3.14.4 插件的视图
3.14.5 组件,助手,行为
3.14.6 插件中的CSS和Javascript
3.14.7 插件的一些诀窍
3.15 全局常量和函数
3.15.1 全局函数
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 核心常量定义
4 CakePHP常用功能
4.1 数据校验
4.1.1 简单规则
4.1.2 每个字段一个规则
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 单字段多规则
4.1.4 核心校验规则
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 自定义校验规则
4.1.5.1 自定义正则表达式
4.1.5.2 添加自己的校验方法
4.1.6 在控制器中校验数据
4.2 数据清理
4.2.1 paranoid
4.2.2 html
4.2.3 escape
4.2.4 clean
4.3 错误处理
4.4 调试
4.4.1 基础调试
4.4.2 使用Debugger类
4.4.3 Debugger类
4.5 缓存
4.6 日志
4.6.1 使用日志记录函数
4.7 测试
4.7.1 测试前的准备
4.7.1.1 安装简单测试包(SimpleTest)
4.7.1.2 执行核心测试用例
4.7.2 测试概览 - 单元测试(Unit testing)与站点测试(Web testing)
4.7.3 准备测试数据
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 本地化和国际化 - Localization & Internationalization
4.8.1 本地化你的Application
4.8.2 Localization in CakePHP
4.9 分页(Pagination)
4.9.1 控制器设置
4.9.2 视图中使用分页
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 简单配置
4.10.2 自定义REST路由
5 核心组件
5.1 访问控制列表(ACL)
5.1.1 理解ACL如何工作
5.1.2 定义权限:基于INI文件的ACL
5.1.3 定义权限:基于数据库的ACL
5.1.3.1 开始
5.1.3.2 创建请求访问对象(AROs)和访问控制对象(ACOs)
5.1.3.3 分配权限
5.1.3.4 检查权限:使用ACL组件
5.2 认证(Authentication)
5.2.1 设置 Auth 组件变量
5.2.2 显示 Auth 错误信息
5.2.3 Auth 疑难解决
5.2.4 改变散列(Hash)函数
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 邮件类属性和变量设定
5.4.1.1 循环发送多封邮件
5.4.2 发送一封简单的邮件
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 方法
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 核心行为(Behavior)
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 前提
6.4.2 基本用法
6.4.2.1 添加数据
6.4.2.2 修改数据
6.4.2.3 删除数据
6.4.2.4 查询以及使用数据
6.4.2.4.1 Children
6.4.2.4.2 子节点计数
6.4.2.4.3 generatetreelist
6.4.2.4.4 getparentnode
6.4.2.4.5 getpath
6.4.3 高级用法
6.4.3.1 moveDown
6.4.3.2 moveUp
6.4.3.3 removeFromTree
6.4.3.4 reorder
6.4.4 数据完整性
7 核心助手(Helper)
7.1 AJAX
7.1.1 AjaxHelper 选项
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 创建表单
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 关闭表单
7.3.3 表单元素
7.3.3.1 字段命名规则
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元素
7.3.4.1 对上传文件进行校验
7.3.5 表单元素-特定方法
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 核心工具库
8.1 App
8.2 Inflector
8.2.1 方法示例
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 的解析
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 核心控制台应用程序
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 应用程序举例
10.1 一个博客的小例子
10.1.1 获取 Cake
10.1.2 创建博客数据库
10.1.3 数据库的配置
10.1.4 可选配置
10.1.5 A Note on mod_rewrite
10.1.6 新建一个Post模型(Model)
10.1.7 Create a Posts Controller
10.1.8 创建一个Post视图
10.1.9 Adding Posts
10.1.10 Data Validation
10.1.11 删除 posts
10.1.12 编辑 Posts
10.1.13 Routes
10.1.14 Conclusion
10.2 ACL应用的简单示例
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 附录
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
1.1 Collection
The Manual
1 Preface
2 Introduction to CakePHP
3 Basic Concepts
4 Installing CakePHP
5 Configuration
6 Scaffolding
7 Models
8 Controllers
9 Views
10 Components
11 Helpers
12 Cake's Global Constants And Functions
13 Data Validation
14 Plugins
15 Access Control Lists
16 Data Sanitation: The Sanitize Class
17 The Cake Session Component
18 The Request Handler Component
19 The Security Component
General
Info
1 CakePHP Development Process
2 Coding Standards
3 Release Checklist
How to help
Unofficial Resources
Sites in the wild
How to ask a question
CakePHP手册
Edit
Comments (0)
History
Compare to original content
关于CakePHP的全部内容
1.3版本 »