Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

BitExpert Blog:
Using Doctrine, ramsey/uuid-doctrine and willdurand/hateoas
Jan 13, 2016 @ 16:29:30

The BitExpert blog has a post sharing some of author Stephan Hochdörfer's experience in combining Doctrine and the ramsey/uuid-doctrine and willdurand/hateoas packages to create a system that follows the HATEOAS API documentation structure for his Doctrine-based objects.

Recently I experimented a bit with Doctrine ORM and the willdurand/Hateoas library to expose my Doctrine objects via an HATEOAS api which luckily is a fairly trivial thing to do. All you need to do is set up the Hateoas serializer and call the respective serialize() method passing your Doctrine object as well the serialization type.

He shares the code to make the integration work, pointing out that the ramsey/uuid-doctrine library makes masking the autoincrement database identifiers (their "id" column) with UUIDs easier. He shows how to integrate this Uuid data type into the Doctrine docblock configuration and how to use the HateoasBuilder to handle the serializer instance containing the Doctrine object/results.

tagged: doctrine uuiddoctrine hateoas api integration builder tutorial

Link: https://blog.bitexpert.de/blog/using-doctrine-ramsey-uuid-and-willdurand-hateoas/

Satish Gopal's Blog:
Building RESTful services - part 2
Mar 28, 2012 @ 16:43:49

In part two of his series (part one is here) on building RESTful interfaces, Satish Gopal talks about things like hypermedia and HATEOAS.

This is part 2 of "Building RESTful services". In Part 1 we talked about Level 1 and Level 2 of the Richardson Maturity Model. [...] Now imagine if you had to [find the URI] for every single website, each having a different kind of document in a different custom format. The internet would certainly not be what it is today. Yet a majority of the APIs built today make us do this. This is where the hypermedia concept comes in.

He describes the concepts behind hypermedia, giving examples of how this sort of data can be included in your API's responses. To illustrate, he includes some "link" information that then points to other data for things like "moreInfo" and "reviews" in his Book example. He also describes HATEOAS (Hypermedia As The Engine Of Application State) showing how to use this "link" information to make it simpler for the end user/application to navigate around between data sources in the application.

tagged: rest webservice series hypermedia hateoas

Link:


Trending Topics: