1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @link https://github.com/vuongxuongminh/laravel-async |
5
|
|
|
* |
6
|
|
|
* @copyright (c) Vuong Xuong Minh |
7
|
|
|
* @license [MIT](https://opensource.org/licenses/MIT) |
8
|
|
|
*/ |
9
|
|
|
define('LARAVEL_START', microtime(true)); |
10
|
|
|
|
11
|
|
|
use Illuminate\Foundation\Application; |
12
|
|
|
|
13
|
|
|
new class { |
14
|
|
|
/** |
15
|
|
|
* Turn the light on. |
16
|
|
|
*/ |
17
|
|
|
public function __construct() |
18
|
|
|
{ |
19
|
|
|
$this->registerComposerAutoload(); |
20
|
|
|
$app = $this->makeApplication(); |
21
|
|
|
$this->boot($app); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Find and load Composer autoload. |
26
|
|
|
*/ |
27
|
|
|
protected function registerComposerAutoload(): void |
28
|
|
|
{ |
29
|
|
|
$autoloadFiles = [ |
30
|
|
|
__DIR__.'/../../../../autoload.php', |
31
|
|
|
__DIR__.'/../../../autoload.php', |
32
|
|
|
__DIR__.'/../../vendor/autoload.php', |
33
|
|
|
__DIR__.'/../../../vendor/autoload.php', |
34
|
|
|
]; |
35
|
|
|
|
36
|
|
|
$autoloadFile = current(array_filter($autoloadFiles, function (string $path) { |
37
|
|
|
return file_exists($path); |
38
|
|
|
})); |
39
|
|
|
|
40
|
|
|
if (false === $autoloadFile) { |
41
|
|
|
throw new RuntimeException('Composer autoload not found!'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
require $autoloadFile; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Boot an application. |
49
|
|
|
* |
50
|
|
|
* @param Application $app |
51
|
|
|
*/ |
52
|
|
|
protected function boot(Application $app): void |
53
|
|
|
{ |
54
|
|
|
$app[Illuminate\Contracts\Console\Kernel::class]->bootstrap(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Make an application and register services. |
59
|
|
|
* |
60
|
|
|
* @return Application |
61
|
|
|
*/ |
62
|
|
|
protected function makeApplication(): Application |
63
|
|
|
{ |
64
|
|
|
if (! file_exists($basePath = $_SERVER['argv'][4] ?? null)) { |
65
|
|
|
throw new InvalidArgumentException('No application base path provided in child process.'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
$app = new Application($basePath); |
69
|
|
|
|
70
|
|
|
$app->singleton( |
71
|
|
|
Illuminate\Contracts\Console\Kernel::class, |
72
|
|
|
class_exists(App\Console\Kernel::class) ? App\Console\Kernel::class : Illuminate\Foundation\Console\Kernel::class |
73
|
|
|
); |
74
|
|
|
$app->singleton( |
75
|
|
|
Illuminate\Contracts\Http\Kernel::class, |
76
|
|
|
class_exists(App\Http\Kernel::class) ? App\Http\Kernel::class : Illuminate\Foundation\Http\Kernel::class |
77
|
|
|
); |
78
|
|
|
$app->singleton( |
79
|
|
|
Illuminate\Contracts\Debug\ExceptionHandler::class, |
80
|
|
|
class_exists(App\Exceptions\Handler::class) ? App\Exceptions\Handler::class : Illuminate\Foundation\Exceptions\Handler::class |
81
|
|
|
); |
82
|
|
|
|
83
|
|
|
return $app; |
84
|
|
|
} |
85
|
|
|
}; |
86
|
|
|
|