Heroku PHP GrapheneDB连接问题

时间:2015-05-12 13:28:13

标签: php heroku neo4j graphenedb

似乎无法将php连接到graphenedb ...

我的代码如下。我使用了文档中提供的示例代码,但没有用。

<?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());
?>

1 个答案:

答案 0 :(得分:1)

我是Alberto,GrapheneDB的创始人之一。我想帮助您解决连接问题。

您确定使用composer正确安装了Neo4jPHP吗? 更新$ composer update文件后,您应该运行composer.json以更新您的依赖项。

Neo4jPHP目前尚未得到积极维护,即使有效,我也鼓励您使用Neoxygen Neoclient。这些是必要的步骤:

composer.json中包含依赖项:

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

更新您的依赖关系

$ composer update

需要库并配置连接:

<?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();

希望这有帮助。