Using routes with prefixes
Often enough we find ourselves needing to separate different areas of our application, not only in terms of code and user interface, but also in terms of functionality. With CakePHP's flexible routing system, we can achieve this and more by using prefixes, which provide us with a way to reimplement certain controller actions in different ways, and reach a particular implementation depending on the prefix being used, if any.
Getting ready
To go through this recipe we need a sample table to work with. Create a table named profiles
, using the following SQL statement:
CREATE TABLE `profiles`( `id` INT UNSIGNED AUTO_INCREMENT NOT NULL, `name` VARCHAR(255) NOT NULL, `email` VARCHAR(255) NOT NULL, `active` TINYINT(1) NOT NULL default 1, PRIMARY KEY(`id`) );
Add some sample data, using the following SQL statements:
INSERT INTO `profiles`(`id`, `name`, `email`, `active`) VALUES (1, 'John Doe', 'john.doe@email.com', 1), (2, 'Jane Doe', 'jane.doe@email.com', 1), (3, 'Mark...