PHP code example of neo4j-php / query-api

1. Go to this page and download the library: Download neo4j-php/query-api 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/ */

    

neo4j-php / query-api example snippets


use Neo4j\QueryAPI\Neo4jQueryAPI;
use Neo4j\QueryAPI\Objects\Authentication;

$client = Neo4jQueryAPI::login('http://localhost:7474', Authentication::basic('username', 'password'));

$query = 'MATCH (n) RETURN n';
$result = $client->run($query);

foreach ($result as $record) {
    print_r($record);
}

$transaction = $client->beginTransaction();

$query = 'CREATE (n:Person {name: $name}) RETURN n';
$parameters = ['name' => 'John Doe'];
$result = $transaction->run($query, $parameters);

$transaction->commit();

$transaction->rollback();
* array
* array
 * array