We've been working on adding support for ORM like querying of data to the CakePHP Webservice plugin by UseMuffin. This allows you to work with webservices in the quick, easy and familiar way you're used to in CakePHP without having to dive into the details of a particular web API.
In this post I'll be explaining the parts of the ORM for webservices and what they're being used for.
Below is the folder structure that the ORM expects parts to be in. This applies to CakePHP applications and plugins.
The first and most important part is the
Webservice. Its the bridge between the ORM and the actual API you're calling. This class is being called by the
Query when data needs to be read from the service.
When data needs to be queried the
Query will call the execute method which will go out to the API and fetch the necessary data. That data will then be parsed and formatted by the
Webservice. When done it will return a
ResultSet containing a set of
Resources and the total number of results available (this will for example be used for pagination).
In the example below we create a
Webservice to fetch articles from a webservice at example.com. Here you can see the articles being turned into a set of
Resources and being returned by the
The next part is the
Endpoint, its essentially the
Table equivalent of webservice ORM. This is what you use to get data out from your webservice using the ORM. For a comprehensive guide to
Endpoints you can check out the CakePHP documentation about
The following methods are currently implemented in the base
This list will increase in size as the ORM continues to be improved. This list will eventually be removed once the webservices ORM is on par with the CakePHP ORM.
Down here is an example of an
Endpoint to get articles fromt the
Webservice shown in the previous example. Note that it sets the
Webservice which it gets from the
Driver that'll have to create as well. For a post to get you started with a
Driver check out this post by David Yell.
The last part is the
Resource, this represents the actual results returned by the API.
The example below the
Resource represents the articles returned when doing a find using on the
If you want some more information feel free to comment on this post.