You are previewing CakePHP Application Development.
O'Reilly logo
CakePHP Application Development

Book Description

Anupom Step-by-step introduction to rapid web development using the open-source MVC CakePHP framework

  • Anupom Step-by-step introduction to rapid web development using the open-source MVC CakePHP framework

  • Walk through the creation of a complete CakePHP Web application

  • Customize the look and feel of applications using CakePHP layouts and views

  • Make interactive applications using CakePHP, JavaScript, and AJAX helpers

  • Ready for the forthcoming release of CakePHP 1.2

  • In Detail

    Cake is a rapid development framework for PHP that uses well-known design patterns and provides a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss of flexibility. It means you can code faster, your code is better, and it makes writing Web 2.0-style apps a snap.

    This book offers step-by-step instructions to learn the CakePHP framework and to quickly develop and deploy web-based applications. It introduces the MVC pattern and coding styles using practical examples. It takes the developer through setting up a CakePHP development and deployment environment, and develops an example application to illustrate all of the techniques you need to write a complete, non-trivial application in PHP. It aims to assist PHP programmers to rapidly develop and deploy well-crafted and robust web-based applications with CakePHP.

    Table of Contents

    1. CakePHP Application Development
    2. Credits
    3. About the Authors
    4. About the Reviewer
    5. Preface
      1. What This Book Covers
      2. Who is This Book for
      3. Conventions
      4. Reader Feedback
      5. Customer Support
        1. Downloading the Example Code for the Book
        2. Errata
        3. Questions
    6. 1. Introduction to CakePHP
      1. What is CakePHP?
        1. A PHP Framework
        2. Common Design Patterns
        3. Rapid Web Development
        4. Works with PHP4 and PHP5
        5. CakePHP is Free and Open Source
      2. Improved Code Structure
        1. Understanding the MVC Pattern
        2. Models
        3. Controllers
        4. Views
        5. How It Works
      3. Faster Development
        1. Less Configuration, More Convention
        2. Auto Code Generation
        3. Quick Access to Related Data
        4. Built-in Commonly Used Functionalities
      4. Versions of CakePHP: 1.1 and 1.2
      5. Summary
    7. 2. A Quick Installation
      1. Downloading CakePHP
            1. Time for Action
            2. What Just Happened?
      2. Platform Requirements
      3. Configuring Apache
        1. AllowOverwrite is Set to All
        2. Mod_rewrite Module is Loaded
      4. Setting Up Cake in Web Root
            1. Time for Action
            2. What Just Happened?
      5. Running Cake for the First Time
      6. Summary
    8. 3. A Quick App
      1. Making Sure the Oven is Ready
      2. CakeTooDoo: a Simple To-do List Application
      3. Configuring Cake to Work with a Database
            1. Time for Action: Creating and Configuring the Database
            2. What Just Happened?
      4. Writing our First Model
            1. Time for Action: Creating the Task Model
            2. What Just Happened?
      5. Writing our First Controller
            1. Time for Action: Creating the Tasks Controller
            2. What Just Happened?
      6. Viewing All Tasks in CakeTooDoo
            1. Time for Action: Viewing All Tasks
            2. What Just Happened?
      7. Adding a New Task
            1. Time for Action: Creating the Add Task Form
            2. What Just Happened?
      8. Editing a Task
            1. What Just Happened?
      9. Adding Data Validation
            1. Time for Action: Adding Data Validation to Check for Empty Title
            2. What Just Happened?
      10. Deleting a Task from CakeTooDoo
            1. Time for Action: Adding Data Validation
            2. What Just Happened?
      11. Viewing Completed Tasks and Pending Tasks
            1. Time for Action: Viewing Completed and Pending Tasks
            2. What Just Happened?
      12. Formatting Date and Time
            1. Time for Action: Formatting the Created and Modified Time
            2. What Just Happened?
      13. Creating the CakeTooDoo Homepage
            1. Time for Action: CakeTooDoo Homepage
            2. What Just Happened?
      14. Summary
    9. 4. Controllers: Programming Application Logic
      1. Interacting with Model
        1. Attaching Models and Controllers
            1. Time for Action: Controller without a Model
            2. What Just Happened?
      2. Action, Parameters, and Views
        1. Interacting with View
            1. Time for Action: Passing Variables to a View
            2. What Just Happened?
        2. Actions and Parameters
            1. Time for Action: Understanding Actions and Parameters
            2. What Just Happened?
            3. Time for Action: Handling more than One Request Parameter
            4. What Just Happened?
            5. How Cake Handles an Incoming Request?
        3. Getting Post Data from the View
            1. Time for Action: Getting Post Data from the View
            2. What Just Happened?
      3. Redirecting
            1. Time for Action: Redirecting from One Action to Another
            2. What Just Happened?
      4. AppController: The Parent Controller
            1. Time for Action: Adding Common Functionalities to all Controllers
            2. What Just Happened?
      5. Working with Components
            1. Time for action: Creating and Using Reusable Components
            2. What Just Happened?
      6. Summary
    10. 5. Models: Accessing Data
      1. Setting Up Database and Models
        1. Creating a Model for a Database Table
            1. Time for Action: Creating a Database Table and Its Model
            2. What Just Happened?
      2. Retrieving Data
        1. Using Model to Retrieve Data
            1. Time for Action: Retrieving Data Using Model
            2. What Just Happened?
        2. More on Data Retrieval
            1. More on find()
            2. Writing Complex Conditions
            3. Magic Find Functions
            4. Reading a Single Field
      3. Saving and Updating Data
        1. Saving Data
            1. Time for Action: Saving Data into the Database
            2. What Just Happened?
        2. Updating a Record
            1. Time for Action: Updating a Database Record
            2. What Just Happened?
        3. More on the save() Method
        4. Updating a Single Field
        5. Batch Update
      4. Deleting Data
        1. Deleting a Single Record
            1. Time for Action: Deleting a Single Record
            2. What Just Happened?
      5. Placing Your Own Logic Inside Model
        1. Create and Use Your Own Model Method
            1. Time for Action: Create and Use Your Own Model Method
            2. What Just Happened?
            3. Making Custom SQL Queries
      6. Validating Your Data
        1. Adding Validation to Our Model
            1. Time for Action: Adding Validation to Our Model
            2. What Just Happened?
            3. More on Data Validation
            4. Custom Validation Methods
      7. Summary
    11. 6. ORM: Modelling the Table Relationship
      1. Working with Simple Associations
        1. Defining One-To-Many Relationship in Models
            1. Time for Action: Defining One-To-Many Relation
            2. What Just Happened?
        2. Retrieving Related Model Data in One-To-Many Relation
            1. Time for Action: Retrieving Related Model Data
            2. What Just Happened?
        3. Saving Related Model Data in One-To-Many Relation
            1. Time for Action: Saving Related Model Data
            2. What Just Happened?
        4. Adding More than One Association of the Same Type
        5. One-To-One Relation
        6. Customizing Association Characteristics
      2. Working with Complex Associations
        1. Defining Many-To-Many Relationship in Models
            1. Time for Action: Defining Many-To-Many Relation
            2. What Just Happened?
        2. Retrieving Related Model Data in Many-To-Many Relation
            1. Time for Action: Retrieving Related Model Data
            2. What Just Happened?
        3. Saving Related Model Data in Many-To-Many Relation
            1. Time for Action: Saving Related Model Data
            2. What Just Happened?
        4. Deleting Associated Data
        5. Changing Association On The Fly
      3. Summary
    12. 7. Views: Creating User Interfaces
        1. Creating Custom Layouts
            1. Time for Action: Creating a Custom Layout
            2. What Just Happened?
      1. Using Elements
        1. Creating and Using Element
            1. Time for Action: Creating and Using Elements
            2. What Just Happened?
      2. Working with Helpers
        1. Creating and Using Your Own Helper
            1. Time for Action
            2. What Just Happened?
        2. Creating Forms to Take User Input
            1. Time for Action
            2. What Just Happened?
      3. Summary
    13. 8. Using Shells: Get Further, Faster
      1. Setting Up the Cake Shell
        1. Setting Up the Cake Shell in Windows
            1. Time for Action: Setting Up the Cake Shell in Windows
            2. What Just Happened?
        2. Setting Up the Cake Shell in *nix
            1. Time for Action: Setting Up the Cake Shell in *nix
            2. What Just Happened?
      2. Baking an Application
        1. Creating and Configuring the Database
            1. Time for Action: Creating and Configuring the Database
            2. What Just Happened?
        2. Baking Models
            1. Time for Action: Baking Models
            2. What Just Happened?
        3. Baking Controllers
            1. Time for Action: Baking Controllers
            2. What Just Happened?
        4. Baking Views
            1. Time for Action: Baking Views
            2. What Just Happened?
      3. Summary
    14. 9. Making Quickwall: The Basics
      1. What is This Quickwall All About?
      2. Setting Up Cake
            1. Time for Action: Setting Up Cake
            2. What Just Happened?
      3. Creating and Connecting the Database
            1. Time for Action
            2. What Just Happened?
      4. Creating and Defining Relationships between Models
            1. Time for Action
            2. What just Happened?
      5. Creating the Basic Controller Actions and Their Views
            1. Time for Action
            2. What Just Happened?
      6. Adding Custom Layout
            1. Time for Action
            2. What Just Happened?
      7. Adding Forms to Add New Questions and Answers
            1. Time for Action
            2. What Just Happened?
      8. Summary
    15. 10. Quickwall: User Authentication
      1. Creating the User Model and the Users Controller
            1. Time for Action
            2. What Just Happened?
      2. Making the User Sign Up Process
            1. Time for Action
            2. What Just Happened?
      3. Adding Email Confirmation to Sign Up
            1. Time for Action
            2. What Just Happened?
      4. Integrating Authentication: Database and Models
            1. Time for Action
            2. What Just Happened?
      5. Integrating Authentication: Controllers
            1. Time for Action
            2. What Just Happened?
      6. Integrating Authentication: Views
            1. Time for Action
            2. What Just Happened?
      7. Remembering User with Cookie
            1. Time for Action
            2. What Just Happened?
      8. Summary
    16. 11. Quickwall: JavaScript and AJAX
      1. Adding JavaScript Validation
            1. Time for Action
            2. What Just Happened?
      2. AJAX Link to Show Own Questions
            1. Time for Action
            2. What Just Happened?
      3. AJAX AutoComplete to Search Users
            1. Time for Action
            2. What Just Happened?
      4. AJAX Form Submit to View Questions of a User
            1. Time for Action
            2. What Just Happened?
      5. In-Line Editing to Edit Own Answers
            1. Time for Action
            2. What Just Happened?
      6. Summary
    17. 12. Quickwall: Making It Better
      1. Making Dates More Readable
            1. Time for Action
            2. What Just Happened?
      2. Creating a User Page
            1. Time for Action
            2. What Just Happened?
      3. Linking the Search Page to the User Page
            1. Time for Action
            2. What Just Happened?
      4. Adding Pagination
            1. Time for Action
            2. What Just Happened?
      5. Adding RSS Feeds
            1. Time for Action
            2. What Just Happened?
      6. Summary