neoxygen / neo4j-neoclient

Simple PHP HttpClient for the Neo4j ReST API with Multi DB Support
MIT License
121 stars 138 forks source link

I need help working with Neo4j database in php #84

Open nkem56 opened 3 years ago

nkem56 commented 3 years ago

Good day Everyone, Am trying to work on neo4j graph database using php. I saw your amazing projects on github

https://github.com/neoxygen/neo4j-neoclient

Please I have install xampp and my php is running locally. I have also installed neo4j graph database and its running locally too. I have also install the projects via composer as per "composer require neoxygen/neoclient"

when I try to connect via your sample code below and print the version. it seems its not connecting. it throws error

Fatal error: Uncaught Neoxygen\NeoClient\Exception\HttpException: Error on Connection "default" with message "Client error: GET http://localhost:7474/db/data resulted in a 401 Unauthorized response: { "errors" : [ { "code" : "Neo.ClientError.Security.Unauthorized", "message" : "No authentication header su (truncated...) " in C:\xampp\htdocs\neo_oxygen\src\EventListener\HttpRequestEventSubscriber.php:74 Stack trace: #0 C:\xampp\htdocs\neooxygen\vendor\symfony\event-dispatcher\EventDispatcher.php(184): Neoxygen\NeoClient\EventListener\HttpRequestEventSubscriber->onHttpException(Object(Neoxygen\NeoClient\Event\HttpExceptionEvent), 'neoclient.http...', Object(Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher)) #1 C:\xampp\htdocs\neooxygen\vendor\symfony\event-dispatcher\EventDispatcher.php(46): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'neoclient.http...', Object(Neoxygen\NeoClient\Event\HttpExceptionEvent)) #2 C:\xampp\htdocs\neo_oxygen\src\HttpClient\GuzzleHttpCl in C:\xampp\htdocs\neo_oxygen\src\EventListener\HttpRequestEventSubscriber.php on line 74

below is your connection Code


<?php

require_once 'vendor/autoload.php';

use Neoxygen\NeoClient\ClientBuilder;

 $client = ClientBuilder::create()
    ->addConnection('default','http','localhost',7474)
    ->build();

$root = $client->getRoot();

//print_r($root);

$version = $client->getNeo4jVersion();
print_r($version);

very important, My neo4j local database server has username: neo4j and password: neo65gbcAB

All I want to implement is how to 1.)Connect to my neo4j local database server 2.) create database eg Test_db via php 3.) insert, select, update and delete data from graph database using php. please can you also help me with that

Thanks

Mulkave commented 3 years ago

The new and supported PHP driver is https://github.com/neo4j-php/neo4j-php-client please go there and install it in your project to enjoy the latest Neo4j versions support.