eZ Community » Forums » Discussions » How to implement a REST-based web...

Sunday 22 April 2012 4:08:28 pm - 4 replies

» Read full blog post


In this blog post I will explain how to implement a REST-based web service with a custom XML scheme in eZ Publish. The setup is somewhat experimental: the REST functionality has only recently been introduced in eZ Publish, and still changes frequently. Moreover, the documentation available at this point is very limited or outdated already. Any feedback on this blog post is more than welcome!

Monday 23 April 2012 6:23:50 pm

Thanks for bringing some much needed light to this shadowy area of eZ.

Apart from the somewhat-overkill feeling of the thing (too many classes, files and controllers come in to play for this simple task), I have one gripe with your approach: you are sticking to eZ "old" concept of letting the views do most of the heavy lifting, which is bad. All the calculations should be done in in the "doThis" methods, and the xml views should just add a thin layer of paint to transform the data gotten from the actions into xml. I understand that running an eZ module+view might be an interesting example, but at least for the "fetch a node" example, the fetch should imho be moved. The final goal is that you can have different views (json, xml, ...) displaying the same data.

Tuesday 24 April 2012 11:37:14 am


Your post is great in that it fully encompasses how to use the REST API as it stands now.  It it is the only complete - 'one stop' place for a full example of the API in it's current state.  About four months ago, I took two days to fully understand and test the API.  This post would have saved me a great abount of time.

People can always question the the stability or suitability of the API itself and judge if it is right for them.  However, if they do use it - or want to test it enough to make an informed decision, this post is definitely the place to start as it describes the use of the current API as it stands - even if the API is in a somewhat state of flux.

The developers seem to have known one thing for sure:  the API is not necessarily complete in many ways.  With that, they had the forethought to put in an API version number into the interface URL so that future improvements can be stacked on top of what is there without loosing backward compatibility.


As a side note: In a recent, large project, we opted away from the eZ API mostly because it seemed to be too much in a state of flux.  Even now, the index_rest.php file still opens with comments about it being used as a 'temporary measure'.  Instead, we have created a limited REST API as a module in an extension that takes the standard ezPublish route and index.php, but saves some overhead by never using the template layer.  Our output translators (JSON, HTML, XML, CUSTOM) are all in PHP.

Tuesday 24 April 2012 3:05:20 pm

@David if you want to go the way of using the standard eZP module/view way, why not use the existing ezjscore or ggwebservices extensions?

Monday 08 April 2013 3:13:27 pm

Using REST API, what steps are needed to create objects into eZ System?

The examples which are given here are for GET method via URL.

How to POST data with REST API into eZ System to create articles using PHP?



You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from