1. Go to this page and download the library: Download primd/fluidgraph 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/ */
primd / fluidgraph example snippets
use Bolt\Bolt;
use Bolt\connection\StreamSocket;
$graph = new FluidGraph\Graph(
[
'scheme' => 'basic',
'principal' => 'memgraph',
'credentials' => 'password'
],
new Bolt(new StreamSocket())
);
use FluidGraph\Node;
use FluidGraph\Entity
class Person extends Node
{
use Entity\Id\Uuid7;
public function __construct(
public ?string $firstName = NULL,
public ?string $lastName = NULL,
) {}
}
use FluidGraph\Edge;
use FluidGraph\Entity;
class FriendsWith extends Edge
{
use Entity\DateCreated;
use Entity\DateModified;
public string $description;
}
use FluidGraph\Node;
use FluidGraph\Entity;
use FluidGraph\Matching;
use FluidGraph\Reference;
use FluidGraph\Relationship\Many;
class Person extends Node
{
use Entity\Id\Uuid7;
// ADDED:
public protected(set) Many $friendships;
public function __construct(
public ?string $firstName = NULL,
public ?string $lastName = NULL,
) {
// ADDED:
$this->friendships = Many::having(
$this,
FriendsWith::class,
Reference::to,
Matching::any,
[
Person::class
]
);
}
}
$matt = new Person(firstName: 'Matt');
$jill = new Person(firstName: 'Jill');