Neo4j and php getting started

Neo4j and php getting started

  • @Tsartsaris

    Posted on 2014-01-13

    ​​​This is a quick way to create your first php file to connect to your neo4j database. If you need haven't set up your database follow this quick way to install it on Ubuntu. Examples below apply for php>5.3.
    First download the connection wrapper from here.
    Put it in a folder on your /var/www directory.
    Next step is to create the php file like so.

    require("phar://neo4jphp.phar"); //require the phar wrapper
    $client = new Everyman\Neo4j\Client('', 7474);//connect to the localhost (at this point if you are working on another server ip change it)
    echo "<pre>";//just to make easy to read the server response
    print_r($client->getServerInfo());//request server info to make sure everything worked out fine

    If we go to the page we createed which in my case is we should see something like this

        [extensions] => Array
        [node] =>
        [node_index] =>
        [relationship_index] =>
        [extensions_info] =>
        [relationship_types] =>
        [batch] =>
        [cypher] =>
        [transaction] =>
        [neo4j_version] => 2.0.0
        [version] => Array
                [full] => 2.0.0
                [major] => 2
                [minor] => 0
                [release] => GA

    This means that we are ok. You can download the files and test by yourself at this link as a tar.gz
    If you have any problem just tweet at the graph blog hash-tag.



Social Me!

Twitter Logo LinkedIn Logo Google+ Logo Tumblr Logo