Creating RESTful API in Cakephp

This tutorial will help you to learn how to create rest api in cakephp. For this we need to follow the following steps:


Step1: Create a database and a table say “users”


Step2: Now we will create the Users Model, Veiw and Controller.

  1. users model:
  2. class User extends AppModel {
  3. }

Step3: Create a restful controller: RestUsersController.php

  1. <?php
  2. class RestUsersController extends AppController {
  3. public $uses = array(‘User’);
  4. public $helpers = array(‘Html’, ‘Form’);
  5. public $components = array(‘RequestHandler’);
  6. public function index() {
  7. $users = $this->User->find(‘all’);
  8. $this->set(array(
  9. ‘users’ => $users,
  10. ‘_serialize’ => array(‘users’)
  11. ));
  12. }
  13. public function add() {

– Read the complete Blog at: Creating RESTful API in Cakephp

FindNerd’s Php questions and answers forum is developed for those tech geeks who don’t want to wait for a longer duration of time, as the community members within FindNerd can answer any android query within shortest possible time frame.

Apart from this, If you have any language query like C, Java, JavaScript, iOS, Html, PHP etc . you can post at FindNerd’s Java developer Forum

Advertisements
Creating RESTful API in Cakephp

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s