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

RESTful resources

You may have heard of REST at some point during your time in development. Representational State Transfer is an API architecture design which exposes resources over a stateless communication, using the HTTP methods of the protocol to facilitate polymorphism through a simplified and uniform API interface.

In this recipe we'll look at how easily REST can be implemented in CakePHP by leveraging the functionality provided by the framework.

Getting ready

For this recipe, we'll set up some standard and custom REST endpoints, which will act against a model. For this, create a table named posts using the following SQL statement:

CREATE TABLE posts ( id INT NOT NULL AUTO_INCREMENT, title VARCHAR(255) NOT NULL, content TEXT, created DATETIME, ...

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