There has been a growing trend to start offering RESTful services for any web product, and Joomla is no exception. With Joomla, however, there is no "preferred" way of writing RESTful services so everyone (that includes us) is trying to build their own component and plugin to enable RESTful services in Joomla. We did the very first REST implementation with Joomla 1.5 which was made as a JSON based alternative to the then existing XML-RPC system that was already present. This blog attempts to list out the various approaches available and the benefits of using each.
This is perhaps the oldest and most common way to do JSON over REST. This method is supported inherently by Joomla and developers just need to provide a view.json.php into each of their views to expose the data from the model via JSON. The framework on Framework (FOF) goes a step further and you don't need to create this file if the default output from the model is sufficient to you.
PROs
CONs
com_api is a component maintained by Techjoomla which follows a plugin based architecture. Developers write apps (plugins) that contain multiple resources. Eg: The user app may have a resource for fetching and saving user data and another resource for login. Similarly, the content app may have resources for articles & categories. This allows implementing all the GET, POST, PUT & DELETE methods.
PROs
CONs
Understanding the need for web services, a very detailed API specification document has been created by Chris Davenport for the web services working group. The POC contains a few sample resources and a suggested/possible implementation of the web services. While this specification does not actually specify how the implementation should be done, it's more of a guideline for the URLs and data structures. A working example of the POC is here.
PROs
CONs
Is there a better way we've missed out? Have anything to add/improve on these? Let us know in the comments below!
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.