Код: Выделить всё
public function __construct($table = null){
$config = config('Database')->neo4j;
if (!empty($config['Username'])){
$auth = Authenticate::basic($config['Username'],$config['Password']);
} else {
$auth = null;
}
$this->transact = $config['Transact']; // allows config setting of whether to use the Transaction feature
$this->client = ClientBuilder::create()->withDriver('bolt','bolt://neo4j:PW_THAT_WORKS@localhost:7687')->build();
$this->table = $table;
}
public function query($query,$params = []){
$client = $this->client;
$statement = new Statement($query,$params);
if ($this->transact){
$result = $client->writeTransaction(static function (TransactionInterface $tsx) use ($statement) {
return $tsx->runStatement($statement);
});
} else {
$result = $client->runStatement($statement);
}
return $result;
}
public function insert($data = null, bool $returnID = true){
if (empty($this->table)){
return false;
}
$result = $this->query('CREATE ('.$this->table. ')');
print'
';print_r($result);print'';
}
Код: Выделить всё
$neo4j = new \App\Models\Neo4jModel('n:Test');
$neo4j->insert(array('Hello'=>'World','Foobar'=>'Baz'));
Код: Выделить всё
Cannot connect to any server on alias: bolt with Uris: ('bolt://neo4j:PW_THAT_WORKS@localhost:7687')Также если я попробую драйвер http, я получу Http\Discovery\Exception\DiscoveryFailedException - что, как я знаю, выглядит очевидным, но, как я уже сказал, мой браузер может нормально получить доступ к локальному хосту! Я захожу из subdomain.localhost, но это не должно быть проблемой?
И запуск Curl приводит к следующему:
Код: Выделить всё
curl localhost:7474 { "bolt_routing" : "neo4j://localhost:7687", "transaction" : "http://localhost:7474/db/{databaseName}/tx", "bolt_direct" : "bolt://localhost:7687", "neo4j_version" : "4.1.12", "neo4j_edition" : "community" }Подробнее здесь: https://stackoverflow.com/questions/768 ... php-client
Мобильная версия