PHP code example of artdarek / neo4j-4-laravel

1. Go to this page and download the library: Download artdarek/neo4j-4-laravel 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/ */

    

artdarek / neo4j-4-laravel example snippets


'providers' => array(
	'Artdarek\Neo4j\Neo4jServiceProvider'
),

	/*
	|--------------------------------------------------------------------------
	| Neo4j Databases
	|--------------------------------------------------------------------------
	*/

	'neo4j' => [
		'default' => [
			'host'     => 'localhost',
			'port'     => 7474,
			'username' => null,
			'password' => null,
		],
	],


return array( 

	/*
	|--------------------------------------------------------------------------
	| Neo4j Config
	|--------------------------------------------------------------------------
	*/
	'default' => array(

		/**
		 * Host
		 */
		'host' => 'localhost',

		/**
		 * Port
		 */	
		'port' => 7474, 

		/**
		 * Credentials
		 */
		'username' => null,
		'password' => null 

	),
);


$arthur = Neo4j::makeNode();
$arthur->setProperty('name', 'Arthur Dent')
    ->setProperty('mood', 'nervous')
    ->setProperty('home', 'small cottage')
    ->save();

$ford = Neo4j::makeNode();
$ford->setProperty('name', 'Ford Prefect')
    ->setProperty('occupation', 'travel writer')
    ->save();

$arthurId = $arthur->getId();



$character = Neo4j::getNode($arthurId);

foreach ($character->getProperties() as $key => $value) {
    echo "$key: $value\n";
}

// prints:
// name: Arthur Dent
// mood: nervous
// home: small cottage

$character->removeProperty('mood')
    ->setProperty('home', 'demolished')
    ->save();

foreach ($character->getProperties() as $key => $value) {
    echo "$key: $value\n";
}

// prints:
// name: Arthur Dent
// home: demolished



$earth = Neo4j::getNode(123);
$earth->delete();


$ php artisan config:publish artdarek/neo4j-4-laravel