Skip to content

Commit 2f4ad18

Browse files
xavismehNyholm
authored andcommitted
Added bolt support (#9)
Typo Fixed minimum requirement
1 parent da5872e commit 2f4ad18

File tree

4 files changed

+43
-17
lines changed

4 files changed

+43
-17
lines changed

DependencyInjection/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ public function getConfigTreeBuilder()
8585
->prototype('array')
8686
->addDefaultsIfNotSet()
8787
->children()
88-
->enumNode('schema')->values(['http', 'bolt'])->defaultValue('http')->end()
88+
->enumNode('schema')->values(['http', 'bolt'])->defaultValue('bolt')->end()
8989
->scalarNode('host')->defaultValue('localhost')->end()
90-
->integerNode('port')->defaultValue(7474)->end()
90+
->integerNode('port')->end()
9191
->scalarNode('username')->defaultValue('neo4j')->end()
9292
->scalarNode('password')->defaultValue('neo4j')->end()
9393
->end()

DependencyInjection/Neo4jExtension.php

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace Neo4j\Neo4jBundle\DependencyInjection;
66

7+
use GraphAware\Bolt\Driver as BoltDriver;
78
use GraphAware\Neo4j\Client\Connection\Connection;
9+
use GraphAware\Neo4j\Client\HttpDriver\Driver as HttpDriver;
810
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
911
use Symfony\Component\Config\FileLocator;
1012
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -48,6 +50,22 @@ public function load(array $configs, ContainerBuilder $container)
4850
}
4951
}
5052

53+
/**
54+
* {@inheritdoc}
55+
*/
56+
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
57+
{
58+
return new Configuration($container->getParameter('kernel.debug'));
59+
}
60+
61+
/**
62+
* {@inheritdoc}
63+
*/
64+
public function getAlias(): string
65+
{
66+
return 'neo4j';
67+
}
68+
5169
/**
5270
* @param array $config
5371
* @param ContainerBuilder $container
@@ -167,20 +185,23 @@ private function getUrl(array $config): string
167185
$config['username'],
168186
$config['password'],
169187
$config['host'],
170-
$config['port']
188+
$this->getPort($config)
171189
);
172190
}
173191

174192
/**
175-
* {@inheritdoc}
193+
* Return the correct default port if not manually set.
194+
*
195+
* @param array $config
196+
*
197+
* @return int
176198
*/
177-
public function getConfiguration(array $config, ContainerBuilder $container): Configuration
199+
private function getPort(array $config)
178200
{
179-
return new Configuration($container->getParameter('kernel.debug'));
180-
}
201+
if (isset($config['port'])) {
202+
return $config['port'];
203+
}
181204

182-
public function getAlias(): string
183-
{
184-
return 'neo4j';
205+
return 'http' == $config['schema'] ? HttpDriver::DEFAULT_HTTP_PORT : BoltDriver::DEFAULT_TCP_PORT;
185206
}
186207
}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ neo4j:
6767
enabled: true
6868
connections:
6969
default:
70-
schema: http #default
71-
host: localhost #default
72-
port: 7474 #default
73-
username: neo4j #default
74-
password: neo4j #default
70+
schema: bolt # default (must be either "http" or "bolt")
71+
host: localhost # default
72+
port: 7474 # optional, will be set to the proper driver's default port if not provided
73+
username: neo4j # default
74+
password: neo4j # default
7575
second_connection:
7676
username: foo
7777
password: bar

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88
{
99
"name": "Tobias Nyholm",
1010
"email": "[email protected]"
11+
},
12+
{
13+
"name": "Xavier Coureau",
14+
"email": "[email protected]"
1115
}
1216
],
1317
"require": {
1418
"php": "^7.0",
1519
"graphaware/neo4j-php-ogm": "^1.0",
16-
"graphaware/neo4j-php-client": "^4.6",
17-
"symfony/framework-bundle": "^3.0"
20+
"graphaware/neo4j-php-client": "^4.6.4",
21+
"symfony/framework-bundle": "^3.0",
22+
"graphaware/neo4j-bolt": "^1.6"
1823
},
1924
"require-dev": {
2025
"phpunit/phpunit": "^5.4",

0 commit comments

Comments
 (0)