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.

    <?php
    require("phar://neo4jphp.phar"); //require the phar wrapper
    $client = new Everyman\Neo4j\Client('127.0.0.1', 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 127.0.0.1/index.php we should see something like this

    Array
    (
        [extensions] => Array
            (
            )
        [node] => http://127.0.0.1:7474/db/data/node
        [node_index] => http://127.0.0.1:7474/db/data/index/node
        [relationship_index] => http://127.0.0.1:7474/db/data/index/relationship
        [extensions_info] => http://127.0.0.1:7474/db/data/ext
        [relationship_types] => http://127.0.0.1:7474/db/data/relationship/types
        [batch] => http://127.0.0.1:7474/db/data/batch
        [cypher] => http://127.0.0.1:7474/db/data/cypher
        [transaction] => http://127.0.0.1:7474/db/data/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.

Tag-cloud

webNeo4Jphpd3jsubuntuworkcypherinternetbootstrapdevelopmentflaskpython

Social Me!

Twitter Logo LinkedIn Logo Google+ Logo Tumblr Logo