|
| 1 | +# Neo4j Symfony Bundle |
| 2 | + |
| 3 | +[](https://github.com/neo4j-contrib/neo4j-symfony/releases) |
| 4 | +[](https://travis-ci.org/neo4j-contrib/neo4j-symfony) |
| 5 | +[](https://scrutinizer-ci.com/g/neo4j-contrib/neo4j-symfony) |
| 6 | +[](https://scrutinizer-ci.com/g/neo4j-contrib/neo4j-symfony) |
| 7 | +[](https://packagist.org/packages/neo4j/neo4j-bundle) |
| 8 | + |
| 9 | + |
| 10 | +## Install |
| 11 | + |
| 12 | +Via Composer |
| 13 | + |
| 14 | +``` bash |
| 15 | +$ composer require neo4j/neo4j-bundle |
| 16 | +``` |
| 17 | + |
| 18 | +Enable the bundle in your kernel: |
| 19 | + |
| 20 | +``` php |
| 21 | +<?php |
| 22 | +// app/AppKernel.php |
| 23 | + |
| 24 | +public function registerBundles() |
| 25 | +{ |
| 26 | + $bundles = array( |
| 27 | + // ... |
| 28 | + new Neo4j\Neo4jBundle\Neo4jBundle(), |
| 29 | + ); |
| 30 | +} |
| 31 | +``` |
| 32 | + |
| 33 | +## Documentation |
| 34 | + |
| 35 | +The bundle is a convenient way of registering services. We register `Connections`, |
| 36 | +`Clients` and `EntityManagers`. You will always have alias for the default services: |
| 37 | + |
| 38 | + * neo4j.driver |
| 39 | + * neo4j.client |
| 40 | + |
| 41 | + |
| 42 | +### Minimal configuration |
| 43 | + |
| 44 | +```yaml |
| 45 | +neo4j: |
| 46 | + drivers: |
| 47 | + default: ~ |
| 48 | +``` |
| 49 | +
|
| 50 | +With the minimal configuration we have services named: |
| 51 | + * neo4j.connection.default |
| 52 | + * neo4j.client.default |
| 53 | + * neo4j.entity_manager.default* |
| 54 | +
|
| 55 | +### Full configuration example |
| 56 | +
|
| 57 | +This example configures the client to contain two instances. |
| 58 | +
|
| 59 | +```yaml |
| 60 | +neo4j: |
| 61 | + profiling: true |
| 62 | + default_driver: high-availability |
| 63 | + connections: |
| 64 | + - alias: high-availability |
| 65 | + dsn: 'neo4j://core1.mydomain.com:7687' |
| 66 | + authentication: |
| 67 | + type: 'oidc' |
| 68 | + token: '%neo4j.openconnect-id-token%' |
| 69 | + priority: 1 |
| 70 | + # Overriding the alias makes it so that there is a backup server to use in case |
| 71 | + # the routing table cannot be fetched through the driver with a higher priority |
| 72 | + # but the same alias. |
| 73 | + # Once the table is fetched it will use that information to auto-route as usual. |
| 74 | + - alias: high-availability |
| 75 | + dsn: 'neo4j://core2.mydomain.com:7687' |
| 76 | + priority: 0 |
| 77 | + authentication: |
| 78 | + type: 'oidc' |
| 79 | + token: '%neo4j.openconnect-id-token%' |
| 80 | + - alias: backup-instance |
| 81 | + dsn: 'bolt://localhost:7687' |
| 82 | + authentication: |
| 83 | + type: basic |
| 84 | + username: '%neo4j.backup-user%' |
| 85 | + password: '%neo4j.backup-pass%' |
| 86 | +``` |
| 87 | +
|
| 88 | +## Testing |
| 89 | +
|
| 90 | +``` bash |
| 91 | +$ composer test |
| 92 | +``` |
| 93 | + |
| 94 | +## Example application |
| 95 | + |
| 96 | +See an example application at https://github.com/neo4j-examples/movies-symfony-php-bolt (legacy project) |
| 97 | + |
| 98 | +## License |
| 99 | + |
| 100 | +The MIT License (MIT). Please see [License File](../LICENSE) for more information. |
0 commit comments