O'Reilly logo

CakePHP 2 Application Cookbook by Jorge González, James Watts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required