Book Image

Neo4j Cookbook

By : Ankur goel, Ankur Goel
Book Image

Neo4j Cookbook

By: Ankur goel, Ankur Goel

Overview of this book

Table of Contents (17 chapters)
Neo4j Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Accessing Neo4j from PHP


PHP is a one of the most popular languages when it comes to web development and it would make this chapter incomplete if we don't mention it.

In this recipe, we will learn how to access the Neo4j graph database using PHP.

Getting ready

Neo4jPHP is the most popular client when its comes to accessing the Neo4j graph database server using PHP.

You can find more information on this at https://github.com/jadell/neo4jphp.

The following steps will get you started with Neo4jPHP:

  1. Neo4jPHP can be installed by typing the following on the command line:

    echo '{"require":{"everyman/neo4jphp":"dev-master"}}' > composer.json && composer install
    
  2. In the PHP script, include the library, which has been installed, using the following command:

    require("vendor/autoload.php")

How to do it…

The following steps will get you started with Neo4jPHP:

  1. Let's access Neo4j from the PHP script:

    <?php
      require('vendor/autoload.php');
      $client = new Everyman\Neo4j\Client ('localhost', 7474);
    print_r...