sngularai / neo4j-bundle

Neo4j的Symfony集成

安装: 753

依赖关系: 0

建议者: 0

安全: 0

星星: 0

关注者: 1

分支: 0

公开问题: 0

类型:symfony-bundle

0.4.9 2023-01-09 11:24 UTC

This package is auto-updated.

Last update: 2024-09-06 13:50:19 UTC


README

Latest Version Build Status Code Coverage Quality Score Total Downloads

安装

通过Composer

$ composer require neo4j/neo4j-bundle

如果您想使用 EntityManager,则需要安装一个 GraphAware OGM

$ composer require graphaware/neo4j-php-ogm:@rc

在您的内核中启用此包

<?php
// app/AppKernel.php

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

文档

该包是注册服务的一种便捷方式。我们注册 ConnectionsClientsEntityManagers。您总是可以访问默认服务的别名

  • neo4j.connection
  • neo4j.client
  • neo4j.entity_manager.*

最小配置

neo4j:
  connections:
    default: ~

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

  • neo4j.connection.default
  • neo4j.client.default
  • neo4j.entity_manager.default*

完整配置

neo4j:
  profiling: 
    enabled: true
  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"
      cache_dir: "%kernel.cache_dir%/neo4j" # defaults to system cache

使用上述配置,我们将拥有以下命名的服务:

  • neo4j.connection.default
  • neo4j.connection.second_connection
  • neo4j.client.default
  • neo4j.client.other_client
  • neo4j.client.other_foobar
  • neo4j.entity_manager.default*

* 注意:如果已安装 graphaware/neo4j-php-ogm,则EntityManagers将可用。

测试

$ composer test

示例应用程序

请参阅示例应用程序: https://github.com/neo4j-examples/movies-symfony-php-bolt

许可证

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