0

I am trying to implement the Graphaware\neo4j client in php neo4j-php-client

I ran composer to download the files to the working directory .www and tried initiating the client using

require_once(BASEPATH.'vendor/autoload.php');

use GraphAware\Neo4j\Client\ClientBuilder;

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

I get this error.

<b>Fatal error</b>:  Class 'GraphAware\Neo4j\Client\ClientBuilder' not found in <b>*path_to_my_www_dir\index.php*</b> on line <b>36</b><br />

Why am i seeing this?

chandan
  • 123
  • 13

3 Answers3

3

I'm the maintainer of GraphAware Neo4j Client.

My bet is that you have been disturbed when reading the README of the repository.

The current master branch contains the code for 4.0@alpha, so if you ran in the command line composer require graphaware/neo4j-php-client chances are high that composer installed the last stable version in the 3.X series and thus the required class doesn't exist there.

I would suggest you try to install the alpha7 version of the client by running :

composer require graphaware/neo4j-php-client:^4.0@alpha

Let me know if you have other issues

Christophe Willemsen
  • 19,399
  • 2
  • 29
  • 36
  • I did try installing version 4. But this is the problem i get. Your requirements could not be resolved to an installable set of packages. Problem 1 - The requested package graphaware/neo4j-php-client could not be found in an y version, there may be a typo in the package name. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your min imum-stability setting – chandan Mar 31 '16 at 10:28
  • ok then try to add it manually to your composer.json file, like here https://github.com/graphaware/reco4php/blob/master/composer.json#L16 – Christophe Willemsen Mar 31 '16 at 10:31
  • Although i have php 5.6+, now i get this. Problem 1 - graphaware/neo4j-php-client 4.0.0-alpha7 requires php >= 5.6 -> your PHP v ersion (5.5.8) does not satisfy that requirement. - graphaware/neo4j-php-client 4.0.0-alpha6 requires php >= 5.6 -> your PHP v ersion (5.5.8) does not satisfy that requirement. - etc..... – chandan Mar 31 '16 at 11:27
  • You don't have PHP5.6 (your PHP version is 5.5.8) – Christophe Willemsen Mar 31 '16 at 11:30
  • @ChristopheWillemsen why isn't Composer downloading 4.0 automatically if that is what is required to get this class? I'm following the **primary documentation** [here](https://github.com/graphaware/neo4j-php-client#installation) and I'm wondering now, how such a documentation can be published without testing it first... – ADTC Jun 19 '16 at 12:17
  • @ADTC His error proves well that he is not running php 5.6 but 5.5.8, which is incompatible (and end of life in a couple of days) with the client v4, so composer will try to install an "installable version of the package" that matches his current configuration. The documentation has no problem and the driver is well tested : travis + in prod at Tesco Mobile Ireland, Wizbii, Musimap, Yoyster, LeisureGroup, World Economic Forum, GraphStory, and many more... – Christophe Willemsen Jun 19 '16 at 12:59
  • @ADTC NB: When the question was written, the lib was still in alpha (Bolt not official yet), since then the stable version was out and the README updated from ^4.0@alpha to the simple package name as you can see here : https://github.com/graphaware/neo4j-php-client/commit/73c1c8bfea3f4e80ee4f4f2e8c7216485314b1e6 – Christophe Willemsen Jun 19 '16 at 13:06
1

We ran into the issue with neo4j-php-client not supporting PHP 5.5 as well. While the "correct" solution is to upgrade to a newer version of PHP, it isn't exactly the most convenient--especially if you just want to start evaluating this library. The only reason that PHP >= 5.6 is required is for Neo4j's bolt protocol, so as long as you stick to using the http protocol instead everything will work fine. In order to get composer to play nice though, you have to make a few changes to neo4j-php-client's composer.json:

  1. Change "php": ">= 5.6" to "php": ">= 5.5"
  2. Replace "graphaware/neo4j-bolt": "^1.5" with "graphaware/neo4j-common": "^3.0"

We ended up forking the library on Github and then updated our composer.json to use our modified version of neo4j-php-client. The relevant parts are:

{
    ...
    "require": {
        ...
        "graphaware/neo4j-php-client": "dev-OptionalBoltSupport"
    },
    ...
    "repositories": [
        ...
        {
            "type": "vcs",
             "url": "https://github.com/wnielson/neo4j-php-client"
        }
    ]
}

After doing this you can run composer update and neo4j-php-client should install fine.

wnielson
  • 11
  • 1
0

You simply need to require vendor/autoload.php as said in documentation.
So require_once 'vendor/autoload.php'; will solve your problem.
The problem is that, even if you are using use ..., your php file didn't know anything about the php class file you're trying to create.
You need to include that file using include or require function.

Isky
  • 1,328
  • 2
  • 14
  • 33