简体   繁体   English

无法在Windows上安装neoclient

[英]Unable to install neoclient on Windows

I am following the directions given here to install neoclient on Windows 7 - https://github.com/neoxygen/neo4j-neoclient 我正在按照此处给出的指示在Windows 7上安装neoclient- https://github.com/neoxygen/neo4j-neoclient

But I get the error - 但是我得到了错误-

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

when I try to run the sample php code. 当我尝试运行示例php代码时。

My code is - 我的代码是-

<?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 - 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"
        }
    }
}

I'm the maintainer of NeoClient. 我是NeoClient的维护者。

I don't think I have ever seen this piece of code somewhere, please point to a link. 我认为我从未在某处看到过这段代码,请指向链接。

Especially, require and use statements should be in the beginning of the file, after the open tag . 特别是, requireuse语句应该在文件的开头,在open tag

Secondly, you don't need to instantiate the client in a try/catch block. 其次,您无需在try/catch块中实例化客户端。

Here is the correct piece of code : 这是正确的代码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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