-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphpmetro
57 lines (43 loc) · 1.22 KB
/
phpmetro
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
51
52
53
54
55
56
57
#!/usr/bin/env php
<?php
/**
* This file is the binary runner for PHPMetro
*
* https://github.com/subiabre/phpmetro
*
* By Facundo Subiabre, email me at: subiabrewd at gmail dot com.
*/
// Find composer autoload
$level = 1;
while ($level < 6) {
$file = \dirname(__DIR__, $level) . '/vendor/autoload.php';
if (\file_exists($file)) {
define('PHPMETRO_VENDOR_AUTOLOAD', $file);
break;
}
$level++;
}
if (!defined('PHPMETRO_VENDOR_AUTOLOAD')) {
$file = __DIR__ . '/vendor/autoload.php';
if (\file_exists($file)) {
define('PHPMETRO_VENDOR_AUTOLOAD', $file);
}
}
// No autoload found
if (!defined('PHPMETRO_VENDOR_AUTOLOAD')) {
fwrite(
STDERR,
'You need to set up the project dependencies using Composer:' . PHP_EOL .
' composer install' . PHP_EOL . PHP_EOL
);
die(1);
}
require PHPMETRO_VENDOR_AUTOLOAD;
use PHPMetro\Console\CommandsLoader;
use SebastianBergmann\Version;
use Symfony\Component\Console\Application;
$version = new Version('X.Y.Z', __DIR__);
$console = new Application('PHPMetro', $version->getVersion());
$console->addCommands((new CommandsLoader)->getCommands());
$console->setDefaultCommand('run', true);
$console->run();