forked from larastan/larastan
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.php
More file actions
52 lines (44 loc) · 1.57 KB
/
Copy pathbootstrap.php
File metadata and controls
52 lines (44 loc) · 1.57 KB
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
<?php
declare(strict_types=1);
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Contracts\Foundation\Application;
use Larastan\Larastan\ApplicationResolver;
use Larastan\Larastan\Support\BootstrapErrorHandler;
use Laravel\Lumen\Application as LumenApplication;
use Orchestra\Testbench\Concerns\CreatesApplication;
if (! defined('LARAVEL_START')) {
define('LARAVEL_START', microtime(true));
}
try {
$applicationPath = getcwd() . '/bootstrap/app.php';
if (file_exists($applicationPath)) { // Applications and Local Dev
$app = require $applicationPath;
} else {
$applicationPath = dirname(__DIR__, 3) . '/bootstrap/app.php';
if (file_exists($applicationPath)) { // Relative path from default vendor dir
$app = require $applicationPath;
} elseif (trait_exists(CreatesApplication::class)) { // Packages
$app = ApplicationResolver::resolve();
}
}
if (isset($app)) {
if ($app instanceof Application) {
$app->make(Kernel::class)->bootstrap();
} elseif ($app instanceof LumenApplication) {
$app->boot();
}
if (! defined('LARAVEL_VERSION')) {
define('LARAVEL_VERSION', $app->version());
}
}
} catch (Throwable $throwable) {
$argv = $_SERVER['argv'] ?? [];
$decorated = null;
if (in_array('--no-ansi', $argv, true)) {
$decorated = false;
} elseif (in_array('--ansi', $argv, true)) {
$decorated = true;
}
(new BootstrapErrorHandler(decorated: $decorated))->handle($throwable);
exit(1);
}