致命错误:未捕获错误:对PHP使用graphaware [英] Fatal error: Uncaught Error: using graphaware for PHP

查看:176
本文介绍了致命错误:未捕获错误:对PHP使用graphaware的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用graphaware连接到neo4j图形数据库.即使在composer.json中使用库,我仍然收到错误消息,指出致命错误:未捕获的错误.这是autoload.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 <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';

这是名为configNeo4j.php的配置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 );
?>

这是文件结构的图像:

现在,当我在使用xampps apache服务器的Web浏览器上运行网页时,出现以下错误消息:

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

严重错误:未捕获的错误:在C:\ xampp \ htdocs \ configNeo4j.php:11中找不到类'GraphAware \ Neo4j \ Client \ Client'堆栈跟踪:#0 {main}抛出在C:\第11行上的xampp \ htdocs \ configNeo4j.php

这可能也有帮助:

这很奇怪,因为我正在eclipse中使用该库,并且还在xampp的php.exe文件中安装了作曲器.如果有人对这个问题有任何解决方案,那么如果您能让我知道如何解决此问题,那就太好了.谢谢!

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.

推荐答案

尝试一下:

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

您的代码是:

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

您无需指定文件的完整路径('c:/xampp/...')

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

哦,无论如何,您是否编辑了autoload.php?如果您使用第三方类或插件,则不必编辑其核心文件.

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.

这篇关于致命错误:未捕获错误:对PHP使用graphaware的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆