-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
42 lines (37 loc) · 985 Bytes
/
bootstrap.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
<?php
declare(strict_types=1);
use TextControl\ReportingCloud\Stdlib\ConsoleUtils;
/**
* This file bootstraps all console scripts:
*
* - test
* - demo
* - bin
*/
/**
* @return string
*/
$autoloadFilename = static function (): string {
// standard composer autoload file
$file = 'autoload.php';
$paths = [
// when installed as a dependency to another project
dirname(__FILE__, 3),
// when installed as a GIT clone
__DIR__ . '/vendor',
];
foreach ($paths as $path) {
$filename = sprintf('%s/%s', $path, $file);
if (is_readable($filename)) {
return $filename;
}
}
$format = "Cannot load composer's %s. Tried: %s. Did you run 'composer install'?";
$message = sprintf($format, $file, implode(', ', $paths));
throw new RuntimeException($message);
};
include $autoloadFilename();
if (!ConsoleUtils::checkCredentials()) {
echo ConsoleUtils::errorMessage();
die(1);
}