I have a simple CakePHP application that allows the user to create and edit messages. And I want to get the application in PhoneGap at some point in the future.
Therefore, I created an API that spits out JSON for use in AJAX requests, but I get the feeling that I am doing it wrong, because I do not use REST or do nothing that distinguishes it from other code in the controller.
eg. (NOTE: I am missing a part to turn it into JSON for this example)
class ApiController extends AppController {
function index() {
$posts= $this->Post->find('all');
$this->set(compact('posts'));
}
}
To create a URL, for example: domain.com/api/posts/all(will create its own route for this), which I can then use with AJAX to use in my mobile application.
Now my question is, what else would it do with REST? I am very new to creating applications, and my strengths are in the interface, and not in the reverse development, so any pointers, help with this will be highly appreciated.
source
share