1. Go to this page and download the library: Download stefanak-michal/bolt 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/ */
stefanak-michal / bolt example snippets
// Choose and create connection class and specify target host and port.
$conn = new \Bolt\connection\Socket('127.0.0.1', 7687);
// Create new Bolt instance and provide connection object.
$bolt = new \Bolt\Bolt($conn);
// Set requested protocol versions ..you can add up to 4 versions
$bolt->setProtocolVersions(5.4);
// Build and get protocol version instance which creates connection and executes handshake.
$protocol = $bolt->build();
// Initialize communication with database
$response = $protocol->hello()->getResponse();
// verify $response for successful initialization
// Login into database
$response = $protocol->logon(['scheme' => 'basic', 'principal' => 'neo4j', 'credentials' => 'neo4j'])->getResponse();
// verify $response for successful login
// Pipeline two messages. One to execute query with parameters and second to pull records.
$protocol
->run('RETURN $a AS num, $b AS str', ['a' => 123, 'b' => 'text'])
->pull();
// Fetch waiting server responses for pipelined messages.
foreach ($protocol->getResponses() as $response) {
// $response is instance of \Bolt\protocol\Response.
// First response is SUCCESS message for RUN message.
// Second response is RECORD message for PULL message.
// Third response is SUCCESS message for PULL message.
}
$conn = new \Bolt\connection\StreamSocket('helloworld.databases.neo4j.io');
// enable SSL
$conn->setSslContextOptions([
'verify_peer' => true
]);
$bolt = new \Bolt\Bolt($conn);