-5

I am using graphaware to connect to a neo4j graph database. I keep getting an error saying Fatal error: Uncaught Error even though I'm using the library in composer.json. Here is the code for the autoload.php:

    <?php
/*
 * This file is part of the GraphAware Neo4j PHP OGM package.
 *
 * (c) GraphAware Ltd <info@graphaware.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
error_reporting(E_ALL | E_STRICT);
$basedir = __DIR__.'/../';
//$basedir = __DIR__.'C:/xampp/htdocs/';
$proxyDir = $basedir.DIRECTORY_SEPARATOR.'_var';
putenv("basedir=$basedir");
putenv("proxydir=$proxyDir");
$loader = require_once __DIR__.'/../vendor/autoload.php';

Here us the code for the configuration php file named configNeo4j.php:

<?php
// Connection to the database

require_once __DIR__.'/vendor/autoload.php';

use GraphAware\Neo4j\Client\Client;
use GraphAware\Neo4j\Client\ClientBuilder;
$client = new Client ();

$client = ClientBuilder::create ()
->addConnection ( 'default', 'http://neo4j:neo4jj@127.0.0.1:7474' )
-> addConnection('bolt', 'bolt://neo4j:neo4jj@127.0.0.1:7687')
->build ();

$query = "MATCH (X) RETURN X";
$result = $client->run ( $query );
?>

Here is an image of the file structure:

enter image description here

Now when I run the webpage on a web browser which I am doing using xampps apache server I get this error message:

Fatal error: Uncaught Error: Class 'GraphAware\Neo4j\Client\Client' not found in C:\xampp\htdocs\configNeo4j.php:11 Stack trace: #0 {main} thrown in C:\xampp\htdocs\configNeo4j.php on line 11

This might also help:

enter image description here

This is strange because I am using the library in eclipse and I have also installed the composer in the php.exe file in xampp. If anyone has any solution to this problem it would be great if you could let me know how this problem can be fixed.Thanks in advance.

2 Answers2

1

try this:

require_once __DIR__.'/vendor/autoload.php';

your code is:

require_once __DIR__.'C:/xampp/htdocs/vendor/autoload.php';

you dont need to specify the full path of the files ('c:/xampp/...')

__DIR__ will give you the current directory of the file you wrote your codes

oh and anyway, did you edit the autoload.php? if you use third party classes or plugins, you should not have to edit their core files.

Valdrinium
  • 1,398
  • 1
  • 13
  • 28
Jacky Supit
  • 469
  • 3
  • 15
  • Yes I did. I got it from here: https://github.com/graphaware/neo4j-php-ogm/blob/master/tests/autoload.php – James Faulkner Oct 06 '17 at 08:27
  • reset their codes. do not edit it. then use the codes i gave you for the configNeo4j.php – Jacky Supit Oct 06 '17 at 08:34
  • even with these changes I now get: Warning: require_once(C:\xampp\htdocs/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\configNeo4j.php on line 6 Fatal error: require_once(): Failed opening required 'C:\xampp\htdocs/../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\configNeo4j.php on line 6 – James Faulkner Oct 06 '17 at 08:37
0

Use better relative path to load autoload file. With this you are also making the app independent from the OS and your filesystem. Just like this:

require_once __DIR__.'/vendor/autoload.php';
luis moyano
  • 100
  • 4