giudicelli/neo4j-bundle

Neo4j 的 Symfony 集成

安装: 6

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 40

类型:symfony-bundle

0.5.0 2021-04-16 14:19 UTC

This package is auto-updated.

Last update: 2024-09-17 15:54:53 UTC


README

这是一个基于 Neo4j Symfony Bundle 的分支,它使用 Laudis Neo4j PHP Client,这是 Neo4j 唯一推荐的客户端。我们摒弃了 GraphAware,因为它很混乱。

安装

通过 Composer

$ composer require giudicelli/neo4j-bundle

如果你想要使用 NodeManager,你需要安装 OGM

$ composer require giudicelli/neo4j-php-ogm

在你的内核中启用该扩展包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Neo4j\Neo4jBundle\Neo4jBundle(),
    );
}

文档

该扩展包是注册服务的一种便捷方式。我们注册 Clients。你将始终有默认服务的别名

  • neo4j.client
  • neo4j.node_manager.*

最小配置

neo4j:
  connections:
    default: ~

在最小配置中,我们拥有以下命名的服务

  • neo4j.connection.default
  • neo4j.client.default
  • neo4j.node_manager.default*

完整配置

neo4j:
  cache_dir: "%kernel.cache_dir%"
  connections:
    default:
      scheme: bolt # default (must be either "http" or "bolt")
      host: localhost # default
      port: 7474 # optional, will be set to the proper driver's default port if not provided
      username: neo4j # default
      password: neo4j # default
    second_connection:
      username: foo
      password: bar
    third_connection:
      dsn: 'bolt://foo:bar@localhost:7687'
  clients:
    default:
      connections: [default, second_connection, third_connection]
    other_client:
      connections: [second_connection]
    foobar: ~ # foobar client will have the "default" connection
  entity_managers:
    default: 
      client: other_client # defaults to "default"

在上面的配置中,我们将拥有以下命名的服务

  • neo4j.client.default
  • neo4j.client.other_client
  • neo4j.client.other_foobar
  • neo4j.node_manager.default*

* 注意:如果安装了 giudicelli/neo4j-php-ogm,NodeManager 才会可用。

测试

$ composer test

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 以获取更多信息。