klaussilveira/neo4j-ogm-bundle

此捆绑包提供 Neo4j PHP 对象图映射器(OGM)与 Symfony2 的简单集成

安装次数: 24,795

依赖项: 0

建议者: 0

安全: 0

星标: 29

关注者: 5

分支: 9

公开问题: 5

类型:symfony-bundle

dev-master 2012-11-20 20:30 UTC

This package is not auto-updated.

Last update: 2024-09-22 03:46:43 UTC


README

此捆绑包将 Louis-Philippe Huberdeau 的 "Neo4j PHP Object Graph Mapper" 简单集成到 Symfony2。Neo4j OGM 是在 Josh Adell 的 Neo4jPHP 上构建的对象管理层。它允许通过 REST 连接器在 Neo4j 图数据库内部操作数据。

安装

要安装此捆绑包,请将以下内容添加到项目的 composer.json 中

"require": {
    // ...
    "klaussilveira/neo4j-ogm-bundle": "dev-master",
}

然后,运行以下命令更新您的供应商

$ composer update

现在在内核中启用捆绑包

<?php
// app/AppKernel.php

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

然后通过在 config.yml 中添加 neo4j_ogm 命名空间来配置捆绑包

neo4j_ogm:
    host: 'localhost'
    port: 7474

恭喜!您现在可以使用 Neo4j OGM 在 Symfony2 中了。

基本用法

要做的唯一一件事是从容器中请求 neo4j.manager 服务以获取 HireVoice\Neo4j\EntityManager 实例。

<?php

$em = $this->container->get('neo4j.manager');
$repo = $em->getRepository('Entity\\User');
$john = $repo->findOneByFullName('John Doe');

$list = $em->createCypherQuery()
    ->startWithNode('john', $john)
    ->match('john -[:follow]-> followedBy <-[:follow]- similarInterest')
    ->match('similarInterest -[:follow]-> potentialMatch')
    ->end('potentialMatch', 'count(*)')
    ->order('count(*) DESC')
    ->limit(10)
    ->getList();

配置

您可以通过更改 config.yml 中的 neo4j_ogm 来轻松配置 Neo4j OGM

neo4j_ogm:
    transport: 'curl'
    host: 'localhost'
    port: 7474
    username: 'test'
    password: '123456'
    proxy_dir: '/tmp'
    debug: true