InfiRest and InfiRestDoctrine, easy REST interface creation in Zend Framework
Posted by Stefan van der Haven on 18 April 2012
Tag(s): Hobbyprojecten, Open Source
Once a year, Infi offers its employees one week to work on a project of their own choosing. This time, I chose to develop a library for the Zend Framework that enables developers to easily implement REST interfaces in their projects. More specifically, REST interfaces that map to an ORM, for which I picked the Doctrine ORM library.
The result, InfiRest and its companion library InfiRestDoctrine, allows a developer to create a REST endpoint for their Doctrine entities with minimal configuration and coding.
How minimal? Apart from the use-this-to-include-the-library stuff, it boils down to a single line in the application.ini file for setting up the REST base URL, plus one additional line for every endpoint that will expose the Doctrine entities. Next, each endpoint needs an endpoint class in the code, which at least should derive from InfiRestDoctrine_Endpoint, contain a reference to the Doctrine entity class it should expose, and a method that provides a Doctrine entity manager. A slightly more detailed description can be found in the quickstart document.

You might ask: why did you choose to make this? To begin with: for the fun of it. After working on several projects built on the Zend framework combined with the Doctrine ORM, I thought it would be nice to make a reusable generic tool for that combination. Secondly, such a tool did not yet exist, and after seeing the elegance of Tastypie, a similar library for the Django framework, I had the feeling that it was possible to create a basic working version within a week.
Currently it still has some rough edges, but if you want to learn more about this library, have a look at the InfiRest GitHub repository.

















