Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

apache - Fatal error: Uncaught Error: using graphaware for PHP

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 <[email protected]>
 *
 * 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 GraphAwareNeo4jClientClient;
use GraphAwareNeo4jClientClientBuilder;
$client = new Client ();

$client = ClientBuilder::create ()
->addConnection ( 'default', 'http://neo4j:[email protected]:7474' )
-> addConnection('bolt', 'bolt://neo4j:[email protected]: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 'GraphAwareNeo4jClientClient' not found in C:xampphtdocsconfigNeo4j.php:11 Stack trace: #0 {main} thrown in C:xampphtdocsconfigNeo4j.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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...