Lobo
Lobo

Reputation: 4157

CakePHP model to web service

I'm developing a web application that doesn't need database. All data comes via REST.

My question is: Is possible to use a model class (extended from AppModel) to manage data from a RESTfull service?, How to do that?, Does CakePHP any way to mapping directly a RESTfull web service?.

I have researched and I have found the $useTable attribute (http://book.cakephp.org/2.0/en/models/model-attributes.html#usetable) but I'm not sure if exists another way to do this in a better way.

My first idea is implement my own functions in a Model and put $useTable to false.

Thank you.

Upvotes: 0

Views: 556

Answers (1)

ndm
ndm

Reputation: 60503

There is no such functionality that ships with CakePHP, but it's relatively easy to implement it on your own.

Check out datasources, they sit between the model and the data, but can also be used standalone, ie you can use datasource instances directly, or indirectly through the model layer (find/save/delete calls are using the datasource CRUD methods).

Checkout https://github.com/nodesagency/CakePHP-Rest-Datasource for some inspiration.

Upvotes: 2

Related Questions