无法在Windows上安装neoclient

时间:2015-11-01 21:15:48

标签: php windows neo4j graphaware neoxygen

我按照这里给出的指示在Windows 7上安装neoclient - https://github.com/neoxygen/neo4j-neoclient

但是我收到了错误 -

<b>Parse error</b>:  syntax error, unexpected 'use' (T_USE) in <b>C:\xampp\htdocs\send.php</b> on line <b>7</b><br />

当我尝试运行示例php代码时。

我的代码是 -

<?php
try
{
    require_once 'vendor/autoload.php';

    use Neoxygen\NeoClient\ClientBuilder;

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

    $version = $client->getNeo4jVersion();
}
catch(Exception $e)
{
    echo $e->getMessage();
}

echo $version;

?>

composer.json -

{
    "name": "neoxygen/neoclient",
    "type": "library",
    "description": "NeoClient is the most advanced Http Client for Neo4j",
    "keywords": [
        "graph",
        "neo4j",
        "cluster",
        "client",
        "high-availibility"
    ],
    "homepage": "http://neoxygen.io",
    "license": "MIT",
    "authors": [
        {
            "name": "Christophe Willemsen",
            "email": "chris@neoxygen.io"
        }
    ],
    "require": {
      "php": ">= 5.5",
      "guzzlehttp/guzzle": "^6.0",
      "monolog/monolog": "~1.1",
      "symfony/yaml": "^2.7",
      "symfony/config": "^2.7",
      "symfony/dependency-injection": "^2.7",
      "symfony/event-dispatcher": "^2.7",
        "graphaware/neo4j-response-formatter": "^1.0"
    },
    "require-dev": {
        "phpspec/phpspec": "~2.0",
        "phpunit/phpunit": "4.*",
        "bossa/phpspec2-expect": "*",
        "behat/behat": "~3.0"

    },
    "autoload": {
        "psr-4": {
            "Neoxygen\\NeoClient\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Neoxygen\\NeoClient\\Tests\\": "tests/Neoxygen/NeoClient/Tests"
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "3.1-dev"
        }
    }
}

1 个答案:

答案 0 :(得分:3)

我是NeoClient的维护者。

我认为我从未见过这段代码,请指向一个链接。

尤其是requireuse语句应位于open tag之后的文件开头。

其次,您不需要在try/catch块中实例化客户端。

以下是正确的代码:

<?php

require_once 'vendor/autoload.php';

use Neoxygen\NeoClient\ClientBuilder;

$client = ClientBuilder::create()
->addConnection('default','http','localhost',7474)
->build();
try
{
    $version = $client->getNeo4jVersion();
}
catch(Exception $e)
{
    echo $e->getMessage();
}
echo $version;
?>