简体   繁体   中英

Heroku PHP GrapheneDB Connection Issue

cant seem to connect php to graphenedb...

my code as below. i used the sample code as provided in the documentation but no use.

<?php

// https://github.com/jadell/neo4jphp
// in composer.json:
// {
//   "require": {
//     "everyman/neo4jphp": "dev-master"
//   }
// }
// require at the top of the script
require('vendor/autoload.php');

// ...

$grapheneUrl = parse_url(getenv('GRAPHENEDB_URL'));

//this line is the problem with heroku... it cant seem to detect the class.
$client = new Everyman\Neo4j\Client($grapheneUrl['host'], $grapheneUrl['port']);
echo var_dump($client);

$client->getTransport()->setAuth($grapheneUrl['user'], $grapheneUrl['pass']);



//print_r($client->getServerInfo());
?>

I'm Alberto, one of the founders of GrapheneDB. I'd like to help you sort out your connection issues.

Have you made sure you have installed Neo4jPHP correctly using composer? You should run $ composer update after updating the composer.json file to update your dependencies.

Neo4jPHP is not currently not actively maintained so even if that works, I'd encourage you to use Neoxygen Neoclient instead. These are the necessary steps:

Include the dependency in composer.json :

{
    "require": {
        "neoxygen/neoclient": "~2.0"
    }
}

Update your dependencies

$ composer update

Require the library and configure the connection:

<?php

require_once 'vendor/autoload.php';

use Neoxygen\NeoClient\ClientBuilder;

$url = parse_url(getenv('GRAPHENEDB_URL'));

$client = ClientBuilder::create()
    ->addConnection('default', $url['scheme'], $url['host'], $url['port'], true, $url['user'], $url['pass'])
    ->setAutoFormatResponse(true)
    ->build();

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM