资料:neo4j的phper
Composer安卓php调用neo4j的扩展。Github:Link
一、安装
github上使用的Symfony框架,而我使用的是laravel框架,不影响框架都遵循psr,自动加载规则。
1、安装即可,neo4j新版就是支持 bolt 连接的4.0版本。老的neo4j只支持http连接,很多php的扩展都老旧了,用不了。
composer require "graphaware/neo4j-php-client:^4.0"
2、具体方法参考github就好了,使用就是这么使用。
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use GraphAware\Neo4j\Client\ClientBuilder;
class Neo4jController extends Controller
{
public $client = null;
public function __construct() {
$this->client = ClientBuilder::create()
->addConnection('bolt', 'bolt://192.168.3.22:7687') // Example for BOLT connection configuration (port is optional)
->build();
}
public function search(Request $request){
$searchTerm = $request->get('q');
$queryTemplate = 'MATCH p=(pe:person)-[r1:has]-(p1:phone)-[r2:registered]-(z1:zello) RETURN p limit 10';
$results = $this->client->run($queryTemplate);
$records = $results->getRecords();
}
}