
CakePHP A Rapid Development Framework Cake Software Foundation Inc. Author and Editor: John Anderson Author and Technical Editor: Larry E Masters CakePHP Programmer's Reference Guide by Cake Software Foundation Inc. Author and Editor: John Anderson Author and Technical Editor: Larry E Masters Version 1.x.x.x (Incomplete) Copyright © 2006 Cake Software Foundation Inc. Abstract This is the official CakePHP manual, This work is licensed under the NEED TO CHOOSE LICENSE; you can see the full terms of the license here [ht- tp://www.cakephp.org]. This is the official manual These conditions may only be waived with prior consent from the Cake Software Foundation Inc.. Table of Contents Preface .............................................................................................................. x 1. Audience ................................................................................................................ x 2. CakePHP is Free .................................................................................................... x 3. Community ............................................................................................................. x 1. Introduction to CakePHP ............................................................................... 11 1.1. What is CakePHP? ............................................................................................. 11 1.2. Why CakePHP? ................................................................................................. 11 1.3. History of CakePHP ........................................................................................... 11 2. Basic Concepts ............................................................................................. 12 2.1. Introduction ........................................................................................................ 12 2.2. The MVC Pattern ............................................................................................... 12 2.3. Overview of the Cake File Layout ........................................................................ 12 3. Installing CakePHP ....................................................................................... 14 3.1. Introduction ........................................................................................................ 14 3.2. Requirements .................................................................................................... 14 3.2.1. Server Requirements ....................................................................................... 14 3.3. Installing CakePHP ............................................................................................ 14 3.3.1. Getting the most recent stable version .............................................................. 14 3.3.2. Unpacking ....................................................................................................... 14 3.4. Setting Up CakePHP .......................................................................................... 15 3.4.1. Development Setup ......................................................................................... 15 3.4.2. Production Setup ............................................................................................. 15 3.4.3. Advanced Setup: Alternative Installation Options ............................................... 16 3.5. Configuring Apache and mod_rewrite .................................................................. 18 3.6. Make Sure It's Working ....................................................................................... 18 4. Configuration ................................................................................................ 19 4.1. Database Configuration ...................................................................................... 19 4.2. Global Configuration ........................................................................................... 20 4.3. Routes Configuration .......................................................................................... 21 4.4. Advanced Routing Configuration: Admin Routing and Webservices ....................... 22 4.5. (Optional) Custom Inflections Configuration ......................................................... 24 5. Scaffolding ................................................................................................... 25 5.1. Cake's Scaffolding is Pretty Cool ......................................................................... 25 5.2. Customizing Scaffold Views ................................................................................ 25 6. Models ......................................................................................................... 27 6.1. What is a model? ............................................................................................... 27 6.2. Model Functions ................................................................................................. 27 6.2.1. User-Defined Functions ................................................................................... 28 6.2.2. Retrieving Your Data ....................................................................................... 28 6.2.3. Saving Your Data ............................................................................................ 31 6.2.4. Model Callbacks .............................................................................................. 33 6.3. Model Variables ................................................................................................. 34 6.4. Associations ...................................................................................................... 35 6.4.1. Introduction ..................................................................................................... 35 6.4.2. Defining and Querying with hasOne .................................................................. 36 6.4.3. Defining and Querying with belongsTo .............................................................. 38 6.4.4. Defining and Querying with hasMany ................................................................ 39 6.4.5. Defining and Querying with hasAndBelongsToMany .......................................... 41 6.4.6. Saving hasAndBelongsToMany ........................................................................ 44 7. Controllers .................................................................................................... 47 7.1. What is a controller? ........................................................................................... 47 7.2. Controller Functions ........................................................................................... 47 7.2.1. Interacting with your Views ............................................................................... 48 7.2.2. User Redirection ............................................................................................. 48 7.2.3. Controller Callbacks ........................................................................................ 49 7.2.4. Other Useful Functions .................................................................................... 49 iv CakePHP 7.3. Controller Variables ............................................................................................ 51 7.4. Controller Parameters ........................................................................................ 53 8. Views ........................................................................................................... 55 8.1. Views ................................................................................................................ 55 8.1.1. Layouts ........................................................................................................... 55 8.1.2. Elements ........................................................................................................ 56 9. Components ................................................................................................. 58 9.1. Presentation ...................................................................................................... 58 9.2. Creating your own .............................................................................................. 58 9.3. Making your components public .......................................................................... 59 10. Helpers ....................................................................................................... 60 10.1. Helpers ............................................................................................................ 60 10.1.1. HTML ........................................................................................................... 60 10.1.2. AJAX ............................................................................................................ 66 10.1.3. Javascript ..................................................................................................... 71 10.1.4. Number ......................................................................................................... 72 10.1.5. Text .............................................................................................................. 73 10.1.6. Time ............................................................................................................. 74 10.1.7. Cache ..........................................................................................................
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages135 Page
-
File Size-