Getting started with Neo4J REST API and PHP
Hurrah! The excellent graph database Neo4J has made early steps towards escaping its embedded Java roots and behaving more like the client/server model most of us LAMP developers understand. Previous attempts to integrate Neo into PHP applications relied on complex PHP/Java bindings that meant that Java had to run on the same machine, or you had to write your own glue in between PHP and Java using some kind network protocol.
Now however, they have released an initial version of an official HTTP REST API. No more magic and glue. Just good old HTTP.
In order to simplify interacting with the Neo REST server from PHP, I knocked up a little PHP client library for it. Its early days for the Neo REST server and its even earlier days for the PHP client, so use with care!
Firstly, head over to the Neo wiki for information on how to get the Neo REST server installed and running. This will guide you through the basics of interacting with the REST API via HTTP using your web browser and command line tools (e.g. CURL).
Once you have it running and have poked it and prodded it using your webbrowser and / or the command line, its time to get going with PHP!
Getting started with Neo REST server and PHP
Make sure you have the Neo REST server running (its best to start the demo with a empty server so all the node numbers match my examples) and navigate into the directory where you downloaded the PHP client. Type ‘php demo.php’ to run the demo file.
If all has gone well, 3 nodes will be added with relationships between then, and you will be presented with a textual diagram representation in the shell window.
So, if it worked, I suggest you open the ‘demo.php’ script and see how it works!