【问题标题】:Heroku PHP GrapheneDB Connection IssueHeroku PHP GrapheneDB 连接问题
【发布时间】:2015-05-12 13:28:13
【问题描述】:

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

【问题讨论】:

    标签: php heroku neo4j graphenedb


    【解决方案1】:

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

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

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

    希望这会有所帮助。

    【讨论】:

    • 谢谢!是的,它有帮助!使用neoxygen 客户端而不是neo4jphp 可以工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-27
    • 2020-04-07
    • 1970-01-01
    • 2020-07-20
    • 2017-10-22
    • 1970-01-01
    • 2018-08-07
    相关资源
    最近更新 更多