PHPackages                             id009/neo4jbundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. id009/neo4jbundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

id009/neo4jbundle
=================

This bundle integrates Neo4j OGM library into Symfony with basic user provider and form integration

3541PHP

Since May 18Pushed 12y ago1 watchersCompare

[ Source](https://github.com/lex009/neo4j-bundle)[ Packagist](https://packagist.org/packages/id009/neo4jbundle)[ RSS](/packages/id009-neo4jbundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Neo4j Bundle
============

[](#neo4j-bundle)

Provides integration [Neo4j PHP Object Graph Mapper](https://github.com/lphuberdeau/Neo4j-PHP-OGM) with Symfony

Installation with Composer
--------------------------

[](#installation-with-composer)

To install this bundle just add following line to "require" section of your composer.json file: `"id009/neo4jbundle": "dev-master"`

Run `php composer.phar update` command. After updating is finished, register the bundle in your AppKernel.php:

```
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new id009\Neo4jBundle\id009Neo4jBundle(),
    );
    // ...
}
```

Configuration
-------------

[](#configuration)

To finish bundle installation, you need configuration that sets up entity managers and connections. Quite full configuration shown below.

```
id009_neo4j:
  connections:
        default:
            host: localhost
            port: 7474
            username: user
            password: pass
    entity_managers:
        default:
            debug: true
            #For pathfinding algorithms refer to Everyman\Neo4j\PathFinder
            pathfinder_algorithm: allSimplePaths
            pathfinder_maxdepth: 5
```

But in most common cases you'll need something looks like this:

```
id009_neo4j:
    connections:
        default:
    entity_managers:
        default:
```

And that's all. In configuration above host is localhost and port is 7474 by default. Debug mode is taken from global debug parameter. Now, after the bundle is installed and configured properly, you can start using it.

Basics
------

[](#basics)

Please, refer to [Neo4j PHP Object Graph Mapper](https://github.com/lphuberdeau/Neo4j-PHP-OGM) readme to understand how OGM works.

If you have a deal with Doctrine ORM Bundle you'll see that basic usage of Neo4j Bundle is pretty straightforward:

```
// Your controller...
$em = $this->get('id009_neo4j.entity_manager');
// Now you have an instance of HireVoice\Neo4j\EntityManager class. You can do whatever you want with it.
$em->getRepository('Acme\AcmeBundle\Entity')->findOneByUsername('ivanpetrov99'); // and so on...
```

Security
--------

[](#security)

This bundle provides basic OGMUser class and Security provider, working the same as the entity provider described in the [cookbook](http://symfony.com/doc/current/cookbook/security/entity_provider.html). Basic security configuration shown below.

```
providers:
      neo4j_provider:
          neo4j: {class: id009\Neo4jBundle\Security\User\OGMUser}
```

Forms
-----

[](#forms)

The bundle wouldn't be useful enough without integration with Symfony forms. So lets get down to it.

For instance you have a Person and City classes as shown below.

```
// Acme\AcmeBundle\Entity\Person

/**
 * @OGM\Entity
 */
class Person
{
    //...

    /**
     * @OGM\ManyToOne
     */
    protected $city;

    //...
}

// Acme\AcmeBundle\Entity\City

/**
 * @OGM\Entity
 */
class City
{
    //...
}
```

It's a good idea to have a form type to select City when editing Person, isn't it? Here is an example:

```
// Acme\AcmeBundle\Form\Type\PersonType

public function buildForm(FormBuilderInterface $builder, array $options)
{
    //...

    $builder->add('city', null, array(
        'class' => 'Acme\AcmeBundle\Entity\City'
    ));

    //...
}
```

Form type will be automatically detected as `neo4j_entity` with options `array('multiple' => false, 'expanded' => false)`, and it will be rendered as dropdown list.

Events
------

[](#events)

OGM provides three types of events:

- Entity create
- Relation create
- Query run

Please, refer to [HireVoice\\Neo4j\\EntityManager](https://github.com/lphuberdeau/Neo4j-PHP-OGM/blob/master/lib/HireVoice/Neo4j/EntityManager.php) for details on these events.

If you want to subscribe on these events you can create your own Subscriber class that implements `Symfony\Component\EventDispatcher\EventSubscriberInterface`. But for convenience the bundle has an abstract class `id009\Neo4jBundle\Event\AbstractSubscriber`, and you can inherit your subscribers from it. For example:

```
namespace Acme\AcmeBundle\Event

//...

class MySubscriber extends AbstractSubscriber
{
    public function onEntityCreate($entity)
    {
        //...
    }

    public function onRelationCreate($relation, $a, $b, $relationship)
    {
        //...
    }

    public function onQueryRun($query, $parameters, $time)
    {
        //...
    }
}
```

Now, after your subscriber is done, register it in your services.yml file:

```
acme_acmebundle.event.subscriber:
    class: 'Acme\AcmeBundle\Event\MySubscriber'
    tags:
        - {name: id009_neo4j.subscriber}
```

If you have several entity manager within your project just add attribute `manager` with entity manager name to the tag

Contributors
------------

[](#contributors)

Alex Belyaev [@lex009](https://github.com/lex009/)

You are always welcome to contribute!

I would appreciate any feedback.

License
-------

[](#license)

MIT

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ce89df2287116787173a9705ddcc6ce97eb0125c337ea375f88b89bcdf3e88b?d=identicon)[lex009](/maintainers/lex009)

---

Top Contributors

[![lex009](https://avatars.githubusercontent.com/u/1351919?v=4)](https://github.com/lex009 "lex009 (31 commits)")

### Embed Badge

![Health badge](/badges/id009-neo4jbundle/health.svg)

```
[![Health](https://phpackages.com/badges/id009-neo4jbundle/health.svg)](https://phpackages.com/packages/id009-neo4jbundle)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M545](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
