NeoClientPHP从Neo4J检索数据时出现问题 [英] NeoClientPHP Issue when retrieving data from Neo4J

查看:207
本文介绍了NeoClientPHP从Neo4J检索数据时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我仍在学习Neo4J图形数据库,并计划将当前的RDBMS迁移到图形数据库中.因此,我一直在寻找如何在PHP/Codeigniter中连接Neo4J的方法,直到我发现Neoxygen-NeoClient就是答案.

Currently, I am still learning the Neo4J Graph Database and plan to migrate my current RDBMS into Graph Database. So I was searching the methodology of how to connect Neo4J in PHP/Codeigniter until i found out that Neoxygen-NeoClient was the answer.

使用composer安装它之后,我打算对其进行测试.我创建了一个名为 connection.php 的新页面,并将其放置在根文件夹中.不幸的是,现在我在本地主机和

After I installed it using composer then i planning to test it. I created a new page called connection.php and placed in a root folder. Unfortunately right now i'm having some problem when to get data from Neo4J in my localhost and

下面是connection.php的内容

And below is the contains of connection.php

<?php
require_once 'vendor/autoload.php';
use Neoxygen\NeoClient\ClientBuilder;
$client = ClientBuilder::create()
->addConnection('default', 'http', 'myserver.dev', 7474, true, 'username', 'password')
->build();
$q = 'MATCH (n:Actor) RETURN n.name';
$client->sendCypherQuery($q);
$result = $client->getRows();
echo $result;
?>

因此,该查询的结果未显示,我想问一下如何在PHP中显示Neo4J的返回查询?

So the result from that query is not shown and i would like to ask how to display the return query from Neo4J in PHP ?

已更新

我正在尝试从此处运行应用程序的示例进行测试 https://github.com/ikwattro/neo4j-neoclient-example

I was trying to testing from your example of running application in here https://github.com/ikwattro/neo4j-neoclient-example

然后我按照您的安装步骤,然后在localhost上运行它 但是仍然无法显示Neo4J的数据,然后在检查Web控制台后出现此错误

Then i followed your installation steps then ran it on localhost But still couldnt display the data from Neo4J then after i check the Web Console, i got this error

http://localhost/search?q = Matrix 无法加载资源:服务器响应状态404(未找到) localhost/graph无法加载资源:服务器以状态404响应(未找到) localhost/search?q = Matrix无法加载资源:服务器以404(未找到)状态响应

http://localhost/search?q=Matrix Failed to load resource: the server responded with a status of 404 (Not Found) localhost/graph Failed to load resource: the server responded with a status of 404 (Not Found) localhost/search?q=Matrix Failed to load resource: the server responded with a status of 404 (Not Found)

所以我想问题是在我完成作曲家安装并且仅得到供应商之后,我没有得到 graph search 文件夹文件夹

So I guess the problem is I don't get the graph and search folder after i did composer installation and i got only vendor folder

composer install --no-dev --optimize-autoloader

您能验证一下吗? 如果不是这种情况,请给我一些解决方案以解决此问题.

Could you please verify this ? If that's not the case, please give me some solution to resolve this issue.

还可以请您解释一下使用来运行应用程序的含义

And also could you please explain what you mean to run application using

http://localhost:8000/import

谢谢

推荐答案

我是NeoClient的维护者.

I'm the maintainer of NeoClient.

首先,如果需要处理结果,则应激活响应格式化程序:

First, if you need to handle results, you should activate the response formatter :

$client = ClientBuilder::create()
->addConnection('default', 'http', 'myserver.dev', 7474, true, 'username', 'password')
->setAutoFormatResponse(true)
->build();

您现在可以通过多种方式获得结果:

You have now multiple possibilities to get your results back :

采用Neo4j浏览器中的表格格式:

In a table format like in the Neo4j browser :

$q = 'MATCH (n:Actor) RETURN n.name';
$result = $client->sendCypherQuery($q)->getResult()->getTableFormat();

或者,如果您想操纵节点和关系对象:

Or, if you want to manipulate nodes and relationships objects :

$q = 'MATCH (n:Actor) RETURN n';
$result = $client->sendCypherQuery($q)->getResult();
$nodes = $result->getNodes();
$relationships = $result->getRelationships();

您还可以通过get方法使用标识符:

You can also make use of the identifier with the get method :

$q = 'MATCH (n:Actor) RETURN n';
$result = $client->sendCypherQuery($q)->getResult();
$actors = $result->get('n');

我用NeoClient在Sitepoint上写了3篇关于Neo4j和PHP的文章,我相信它们可以为您提供帮助:

I wrote 3 articles on Sitepoint about Neo4j and PHP with NeoClient, I'm sure they can help you :

http://www.sitepoint.com/author/ikwattro/

更新

我检查了一段时间前的 Neo4j-MovieDB存储库更新了自述文件,介绍了如何在本地对其进行测试.

I checked the Neo4j-MovieDB-Repository I did a while ago, and I updated the README with how to test it locally.

对于您的最新问题:

  1. 确保在定义了正确的根路径的情况下运行Web服务器,因此,如果当前目录为$ myrepo/web,则php -S localhost:8000就可以了,如果位于父目录中,则需要提供Web索引根作为参数php -S localhost:8000 -t web/

  1. Make sure you run the webserver with the good root path defined, so if your current directory is $myrepo/web, then php -S localhost:8000 will be ok, if you are in the parent directory, you need to provide the web index root as argument php -S localhost:8000 -t web/

使用http://localhost:8000/importdb网址是为了将数据加载到数据库中,否则他将找不到电影和演员.

the url http://localhost:8000/importdb is made in order to load data in the database, otherwise he will not find movies and actors.

如果您仍然有错误或问题,请在Github上打开一个单独的SO问题或触发问题

If you still have errors or issues, please open a separate SO question or trigger an issue on Github https://github.com/ikwattro/neo4j-moviedb-example/issues

这篇关于NeoClientPHP从Neo4J检索数据时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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