OneWheeledBicycle

Random mutterings of Alastair James

Getting started with Neo4J REST API and PHP

leave a comment »

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

Head over to the github page for the PHP client and download it. If you are familiar with git, you may as well grab the latest version, otherwise I have zipped up a version here.

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.

To confirm it works, you can view the nodes in your browser (http://localhost:9999/node/1, http://localhost:9999/node/2, http://localhost:9999/node/3).

So, if it worked, I suggest you open the ‘demo.php’ script and see how it works!


About these ads

Written by aljames

June 1, 2010 at 11:57 pm

Posted in Neo4J, PHP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: