PHP code example of xp-forge / neo4j

1. Go to this page and download the library: Download xp-forge/neo4j library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xp-forge / neo4j example snippets


use com\neo4j\Graph;
use util\cmd\Console;

$g= new Graph('http://user:[email protected]:7474/db/data');
$q= $g->open('MATCH (t:Topic) RETURN t.name, t.canonical');
foreach ($q as $record) {
  Console::writeLine('#', $record['t.canonical'], ': ', $record['t.name']);
}

if ($topic= $g->fetch('MATCH (t:Topic{id:%s}) RETURN t', $id)) {
  Console::writeLine('Found topic ', $topic);
}

use com\neo4j\Graph;
use util\cmd\Console;

$g= new Graph('http://user:[email protected]:7474/db/data');
$g->query('CREATE (p:Person) SET t.name = %s, t.id = %d', $name, $id);