Book Image

CakePHP Application Development

By : Ahsanul Bari, Anupom Syam
Book Image

CakePHP Application Development

By: Ahsanul Bari, Anupom Syam

Overview of this book

<p>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.<br /><br />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.</p>
Table of Contents (18 chapters)
CakePHP Application Development
Credits
About the Authors
About the Reviewer
Preface
Index

Baking an Application


In CakePHP, automatic code generation is called Baking. An entire application can be generated with all CRUD operations from a few database tables without writing a single line of code. Baking is a great relief for lazy programmers. Moreover, it can be used to generate a basic skeleton application to get up and running. The bake script can be run from the command line. We will now see how a database can be configured using the 'bake' routine.

Creating and Configuring the Database

The bake script can be used to create the database configuration file. As we already know, a database configuration file is used to associate a database to a Cake application. Let's see how the bake script can help us to create such a database configuration file.

Time for Action: Creating and Configuring the Database

  1. Create a database named rapidcake with three tables (posts, users, and comments) using the following SQLs:

    CREATE DATABASE `rapidcake`;
    USE `rapidcake`;
    CREATE TABLE `posts` (...