neo4j/neo4j-bundle

Neo4j 的 Symfony 集成

安装次数: 68,536

依赖项: 0

建议者: 0

安全: 0

星标: 77

关注者: 15

分支: 40

开放问题: 10

类型:symfony-bundle

1.0.0-rc1 2023-06-06 10:11 UTC

This package is auto-updated.

Last update: 2024-09-16 10:13:55 UTC


README

Latest Version Build Status Code Coverage Quality Score Total Downloads

安装

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

不使用 Symfony Flex 的应用程序

步骤 1: 下载 Bundle

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

$ composer require neo4j/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)。请参阅 许可文件 获取更多信息。