kitlabs/neo4j-bundle

Neo4j 的 Symfony 集成

安装: 1

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 40

类型:symfony-bundle

10.4.2 2024-02-21 08:28 UTC

This package is auto-updated.

Last update: 2024-09-21 09:50:38 UTC


README

Latest Version Build Status Code Coverage Quality Score Total Downloads

安装

确保全局已安装 Composer,如 Composer 文档中的 安装章节 所述。

不使用 Symfony Flex 的应用程序

步骤 1: 下载 Bundle

打开命令行,进入项目目录,然后执行以下命令以下载此 Bundle 的最新稳定版本

$ composer require kitlabs/neo4j-bundle

步骤 2: 启用 Bundle

然后,通过将其添加到项目 config/bundles.php 文件中注册的 Bundle 列表中启用该 Bundle

// config/bundles.php

return [
    // ...
    \Neo4j\Neo4jBundle\Neo4jBundle::class => ['all' => true],
];

文档

该 Bundle 是注册服务的便捷方式。我们注册了 Drivers 和一个 Clients。您将始终有默认服务的别名

  • neo4j.driver
  • neo4j.client

最小配置

neo4j:
  drivers:
    default: ~

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

  • neo4j.driver.default
  • neo4j.client

完整配置示例

此示例配置客户端包含两个实例。

neo4j:
  profiling: true
  default_driver: high-availability
  connections:
    - alias: high-availability
      dsn: 'neo4j://core1.mydomain.com:7687'
      authentication:
        type: 'oidc'
        token: '%neo4j.openconnect-id-token%'
      priority: 1
    # Overriding the alias makes it so that there is a backup server to use in case
    # the routing table cannot be fetched through the driver with a higher priority
    # but the same alias.
    # Once the table is fetched it will use that information to auto-route as usual.
    - alias: high-availability
      dsn: 'neo4j://core2.mydomain.com:7687'
      priority: 0
      authentication:
        type: 'oidc'
        token: '%neo4j.openconnect-id-token%'
    - alias: backup-instance
      dsn: 'bolt://localhost:7687'
      authentication:
        type: basic
        username: '%neo4j.backup-user%'
        password: '%neo4j.backup-pass%'

测试

$ composer test

示例应用程序

https://github.com/neo4j-examples/movies-symfony-php-bolt(旧项目)中查看示例应用程序

许可证

MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件