forked from jadell/neo4jphp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stub.php
50 lines (41 loc) · 1.5 KB
/
stub.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
Phar::mapPhar('neo4jphp.phar');
spl_autoload_register(function ($className) {
if (strpos($className, 'Everyman\Neo4j\\') !== 0) {
return;
}
$libPath = 'phar://neo4jphp.phar/lib/';
$classFile = str_replace('\\',DIRECTORY_SEPARATOR,$className).'.php';
$classPath = $libPath.$classFile;
if (file_exists($classPath)) {
require($classPath);
}
});
if ('cli' === php_sapi_name() && basename(__FILE__) === basename($_SERVER['argv'][0])) {
$command = empty($_SERVER['argv'][1]) ? '-help' : $_SERVER['argv'][1];
$me = new Phar('neo4jphp.phar');
$meta = $me->getMetaData();
if ($command == '-help') {
echo <<<HELP
Neo4jPHP version {$meta['version']}
{$_SERVER['argv'][0]} [-help|-license|-readme|-version|<host>] <port>
-help Display help text
-license Display software license
-readme Display README
-version Display version information
<host> (<port>) Test connection to Neo4j instance on host (port defaults to 7474)
HELP;
} else if ($command == '-license') {
echo file_get_contents('phar://neo4jphp.phar/LICENSE')."\n\n";
} else if ($command == '-readme') {
echo file_get_contents('phar://neo4jphp.phar/README.md')."\n\n";
} else if ($command == '-version') {
echo "Neo4jPHP version {$meta['version']}\n\n";
} else {
$port = empty($_SERVER['argv'][2]) ? 7474 : $_SERVER['argv'][2];
$client = new Everyman\Neo4j\Client(new Everyman\Neo4j\Transport($command, $port));
print_r($client->getServerInfo());
}
exit(0);
}
__HALT_COMPILER();