Book Image

CakePHP 2 Application Cookbook - Third Edition

By : Watts
Book Image

CakePHP 2 Application Cookbook - Third Edition

By: Watts

Overview of this book

If you are a CakePHP developer looking to ease the burden of development, then this book is for you. As a headfirst dive into the framework, this collection of recipes will help you get the most out of CakePHP, and get your applications baked in no time. Even if you're not familiar with the framework, we'll take you from basic CRUD building to useful solutions that will aid in getting the job done quickly and efficiently.
Table of Contents (14 chapters)
13
Index

Adding a prefix

Prefixes are additional values prepended to the URL, which allow you to clearly separate collections of actions in your controllers. This is typically used to rapidly create an admin area for an application.

In this recipe, we'll create an inventory management area to a books controller, where the standard actions will simply display details of books and the inventory area will be used to manage our books.

Getting ready

For this recipe, we'll need a table for our books, so create a table named books by using the following SQL statement:

CREATE TABLE books (
  id VARCHAR(36) NOT NULL,
  name VARCHAR(100),
  stock INT(4),
  created DATETIME,
  modified DATETIME,
  PRIMARY KEY(id)
);

We'll then need some sample data, so run the following SQL statement to insert some books:

INSERT INTO books (id, name, stock, created, modified)
VALUES
('635c460a-f230-4565-8378-7cae01314e03', 'CakePHP Application', 2, NOW(), NOW()),
('635c4638-c708-4171-985a...