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") ...

Get Neo4j Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.