/
grumphp
executable file
·51 lines (43 loc) · 1.55 KB
/
grumphp
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
#!/usr/bin/env php
<?php
use GrumPHP\Configuration\ContainerFactory;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
(function () {
// First load current projects autoloader for smarter global / phar installs ....
// A bit opinionated at the moment though:
$autoloaderInWorkingDirectory = getcwd() . '/vendor/autoload.php';
if (is_file($autoloaderInWorkingDirectory)) {
require_once $autoloaderInWorkingDirectory;
}
// Next load the GrumPHP autoloader
$loaded = array_reduce(
[
__DIR__.'/../vendor/autoload.php', // (Normal bin dir)
__DIR__.'/../../../autoload.php', // From location inside folder
__DIR__.'/../../vendor/autoload.php' // (Development integration)
],
static function (?string $loaded, string $file): ?string {
if ( ! $loaded && is_file($file)) {
require_once($file);
return $file;
}
return $loaded;
}
);
if (!$loaded) {
fwrite(
STDERR,
'You must set up the project dependencies, run the following commands:'.PHP_EOL.
'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
'php composer.phar install'.PHP_EOL
);
exit(1);
}
$container = ContainerFactory::build(
$input = new ArgvInput(),
$output = new ConsoleOutput()
);
$application = $container->get('GrumPHP\Console\Application');
$application->run($input, $output);
})();