資料: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();
}
}