This is the first blog entry for Radius Desk
It will make use of CakePHP 2.X as a RESTfull interface
It will also make use of Extjs4 to create a Webtop (Desktop running in the browser)
We will start with a device and conquer approach. The following sections will discuss how to do this approach.
RESTfull services are suppose to be stateless.
In order to do this in CakePHP while maintaining a secure API we will assign a token to each user and use this token as the username with basic authentication when doing RESTfull requests to CakePHP
Task | Progress |
---|---|
Design a basic database with users, groups, aros and acros | 0% |
Create a dummy RESTfull interface that will make use of a token | 0% |
Create a CakePHP shell to test the RESTfull interface | 0% |
In the file radiusdesk/Config/Routes.php add the following:
//Specify which resources (controllers) should be mapped to the RESTfull interface Note the smalls Router::mapResources(array('users','groups')); //Inform CakePHP to also consider .json URLs Router::parseExtensions('json');
Also add the following component to the AppController
public $components = array('RequestHandler');
Also you need to modify the output of a controller action to include the _serialize
~~~~~~~~
public function index() {
$this->User->recursive = 0;
$this->set('users', $this->paginate());
$this->set('_serialize', 'users');
}
~~~~~~~
Note that you do not have to create a json view explicitly to a RESTFull request for JSON
This will allow us to work with the RESTfull interface as follows:
HTTP format | URL.format | Controller action invoked |
---|---|---|
GET | /recipes.format | RecipesController::index() |
GET | /recipes/123.format | RecipesController::view(123) |
POST | /recipes.format | RecipesController::add() |
PUT | /recipes/123.format | RecipesController::edit(123) |
DELETE | /recipes/123.format | RecipesController::delete(123) |
POST | /recipes/123.format | RecipesController::edit(123) |