0

似乎无法将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());
?>
4

1 回答 1

1

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

你确定你已经使用 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();

希望这可以帮助。

于 2015-05-12T14:57:08.037 回答