Prototype JSON-LD/Hydra wrapper for BreweryDB API

Hi All,

In my spare time I've been working on a JSON-LD wrapper for BreweryDB and have
reached what I consider to be a demo-able state.

Basically I have a pretty simple (and hacky) PHP script that manipulates the
JSON repsonses from the BrewerDB API into JSON-LD.
It doesn't provide full coveage of the API yet and needs a bit of tidying, I've
put it in a Gist if anyone cares to take a look [2] (bear in mind this is the
first thing I've done in PHP).
Curently it only works fully with the beer endpoints [3] from the original API.

I'm trying to figure out how to handle all the variations in the JSON structure
without using a load of repetition, nested if-then-else and foreach loops, so if
anyone with some PHP knowhow can suggest a better method, I'm all ears.
Also would like to know how I can get rid of index.php out of the following
URIs.

Some examples:

A beer:
http://brewerydb.semaku.com/index.php/beer/9JFYsa

A beer with it's breweries:
http://brewerydb.semaku.com/index.php/beer/9JFYsa?withBreweries=Y

A paginated collection of beers of 4% ABV:
http://brewerydb.semaku.com/index.php/beers?abv=4

These support conneg (to some extent), so you'll probably get plain old JSON if
you open them in your browser.
If you put them into the JSON-LD playground, you should get the JSON-LD e.g.:
http://json-ld.org/playground/#startTab=tab-nquads&json-ld=http%3A%2F%2Fbrewerydb.semaku.com%2Findex.php%2Fbeer%2F9JFYsa

I'm also using a bit of Hydra, for example the /beers list endpoint is a
hydra:PagedCollection and I added the links to first, last, previous and next
pages.
I am also going to extend the vocabulary to use more Hydra to, for example,
indicate which properties are a hydra:Link  and perhaps detail out some IRI
templates.
However as this is just a learning exercise I probably will not cover all
possibilites offered by the original API, but hopefully enough to convince the
BrweryDB guys to implement it themselves.

Comments welcome!

p.s. this is using my API key right now, so might exceed my limits if too many
requests are made (3.5K per day I think).

[1] http://www.brewerydb.com/
[2] https://gist.github.com/jaw111/46209e853f83d041a6dd
[3] http://www.brewerydb.com/developers/docs-endpoint/beer_index

Regards,

John Walker
Principal Consultant & co-founder
Semaku B.V.
SFJ 4.009, Torenallee 20, 5617 BC Eindhoven
Mobile: +31 6 475 22030
Email: john.walker@semaku.com
Skype: jaw111

KvK: 58031405
BTW: NL852842156B01
IBAN: NL94 INGB 0008 3219 95

Received on Sunday, 28 December 2014 11:51:59 UTC