简体   繁体   English

NeoClientPHP从Neo4J检索数据时出现问题

[英]NeoClientPHP Issue when retrieving data from Neo4J

Currently, I am still learning the Neo4J Graph Database and plan to migrate my current RDBMS into Graph Database. 目前,我仍在学习Neo4J图形数据库,并计划将当前的RDBMS迁移到图形数据库中。 So I was searching the methodology of how to connect Neo4J in PHP/Codeigniter until i found out that Neoxygen-NeoClient was the answer. 因此,我一直在寻找如何在PHP / Codeigniter中连接Neo4J的方法,直到我发现Neoxygen-NeoClient是答案。

After I installed it using composer then i planning to test it. 使用composer安装它之后,我打算对其进行测试。 I created a new page called connection.php and placed in a root folder. 我创建了一个名为connection.php的新页面,并将其放置在根文件夹中。 Unfortunately right now i'm having some problem when to get data from Neo4J in my localhost and 不幸的是现在我在本地主机上从Neo4J获取数据时遇到了一些问题

And below is the contains of connection.php 下面是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;
?>

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 ? 因此,该查询的结果未显示,我想问一下如何在PHP中显示Neo4J的返回查询?

Updated 更新

I was trying to testing from your example of running application in here https://github.com/ikwattro/neo4j-neoclient-example 我正在尝试从您在此处运行应用程序的示例中进行测试, 网址为https://github.com/ikwattro/neo4j-neoclient-example

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 然后,我按照您的安装步骤运行,然后在localhost上运行,但仍然无法显示Neo4J的数据,然后在检查Web控制台后,出现此错误

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) http:// localhost / search?q = Matrix加载资源失败:服务器以404(未找到)状态响应localhost / graph加载资源失败:服务器以404(未找到)状态响应localhost / search?q = Matrix无法加载资源:服务器以状态404(未找到)响应

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

Thanks before 之前感谢

I'm the maintainer of NeoClient. 我是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 : 现在,您可以通过多种方式获得结果:

In a table format like in the Neo4j browser : 以类似于Neo4j浏览器中的表格格式:

$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();

You can also make use of the identifier with the get method : 您还可以通过get方法使用标识符:

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

I wrote 3 articles on Sitepoint about Neo4j and PHP with NeoClient, I'm sure they can help you : 我在Sitepoint上用NeoClient写了3篇关于Neo4j和PHP的文章,我相信它们可以为您提供帮助:

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

UPDATE UPDATE

I checked the Neo4j-MovieDB-Repository I did a while ago, and I updated the README with how to test it locally. 我检查了前一段时间做的Neo4j-MovieDB-Repository ,并更新了自述文件以了解如何在本地对其进行测试。

For your updated questions : 对于您的更新问题:

  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/ 确保使用定义好的根路径运行网络服务器,因此,如果当前目录为$ myrepo / web,则php -S localhost:8000可以,如果位于父目录中,则需要提供网络索引根作为参数php -S localhost:8000 -t web/

  2. the url http://localhost:8000/importdb is made in order to load data in the database, otherwise he will not find movies and actors. URL http://localhost:8000/importdb是为了在数据库中加载数据而创建的,否则他将找不到电影和演员。

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 如果您仍然有错误或问题,请在Github上打开一个单独的SO问题或触发一个问题https://github.com/ikwattro/neo4j-moviedb-example/issues

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM