Skip to content

ryantology/CakePHP-Rest-Datasource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Installation

app/Config/bootstap.php

<?php
CakePlugin::load('Rest');
?>

Database config

<?php
class DATABASE_CONFIG {

        public $sample = array(
                'datasource'            => 'Rest.RestSource',
                'host'                  => 'http://api.example.com',
                'format'                => 'json',
                'encoding'              => 'utf-8',
        );

}
?>

Examlpes

Cake inflection REST endpoint

<?php
class User extends AppModel {

        public $useDbConfig = 'sample';

        public $remoteResource = 'users';

}
?>
User::find('all')               == GET    http://api.example.com/users.json
User::read(null, $id)           == GET    http://api.example.com/users/$id.json
User::save()                    == POST   http://api.example.com/users.json
User::save(array('id' => $id))  == PUT    http://api.example.com/users/$id.json
User::delete($id)               == DELETE http://api.example.com/users/$id.json

More to come later

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published