public function testFailureCanBeDisabled() { $listener = new EventListener(); $client = ClientBuilder::create()->addConnection('default', 'bolt://localhost')->registerEventListener(Neo4jClientEvents::NEO4J_ON_FAILURE, array($listener, 'onFailure'))->build(); $client->run('MATCH (n)'); $this->assertInstanceOf(Neo4jExceptionInterface::class, $listener->e); }
/** * @setUp() */ public function setUp() { $this->recoService = RecommenderService::create('http://localhost:7474'); $this->recoService->registerRecommendationEngine(new RecoEngine()); $this->client = ClientBuilder::create()->addConnection('default', 'http://localhost:7474')->build(); $this->createGraph(); }
public static function conf($username = null, $password = null, $server = 'localhost', $port = 7474) { try { // for 3.4 /* self::$client = \Neoxygen\NeoClient\ClientBuilder::create() ->addConnection('default', 'http', $server, $port, true, $username, $password) ->build(); */ // for 4.0 $credentials = is_null($username) ? "" : "{$username}:{$password}"; self::$client = \GraphAware\Neo4j\Client\ClientBuilder::create()->addConnection('default', "http://{$credentials}@{$server}:{$port}")->build(); } catch (\Exception $e) { throw new exc\Database(array('msg' => 'Database initialization error.', 'previous' => $e)); } }
public function __construct($uri) { $this->driver = ClientBuilder::create()->addConnection('default', $uri)->build(); }
public function testExceptionHandling() { $client = ClientBuilder::create()->addConnection('default', 'bolt://localhost')->build(); $this->setExpectedException(Neo4jException::class); $result = $client->run("CREATE (n:Cool"); }
public function setUp() { $this->client = ClientBuilder::create()->addConnection('default', 'bolt://localhost')->build(); }
<?php require __DIR__ . '/vendor/autoload.php'; require __DIR__ . '/Customer.php'; require __DIR__ . '/Order.php'; require __DIR__ . '/Product.php'; $client = \GraphAware\Neo4j\Client\ClientBuilder::create()->addConnection('bolt', 'bolt://*****:*****@localhost:7687')->build(); $entityManager = new \GraphAware\Neo4j\OGM\EntityManager($client); /** @var \GraphAware\Bolt\Result\Result $result */ $result = $client->run('MATCH (customer:Customer {email: { email }})-[cpo:PLACED]-> (order)-[ocp:CONTAINS]->(product) RETURN customer, cpo, order, ocp, product', ['email' => '*****@*****.**']); $customer = $entityManager->getRepository(Customer::class)->findOneBy('email', '*****@*****.**'); foreach ($customer->orders as $order) { $products = array_reduce($order->products->toArray(), function ($productNames, $product) { $productNames[] = $product->name; return $productNames; }); echo sprintf("%s ordered [%s] on %s\n", $customer->name, implode(', ', $products), $order->date); }
/** * @param string $host * * @return \GraphAware\Neo4j\OGM\EntityManager */ public static function buildWithHost($host) { $client = ClientBuilder::create()->addConnection('default', $host)->build(); return new self($client); }
public function testExceptionIsThrownWhenMasterAliasDoesntExist() { $this->setExpectedException(InvalidArgumentException::class); $client = ClientBuilder::create()->addConnection('default', 'http://localhost:7474')->addConnection('conn2', 'http://localhost:7575')->addConnection('conn3', 'http://localhost:7676')->setMaster('conn5')->build(); }