Skip to content

Commit ccb4e85

Browse files
Avoid "Warning: Constant LARAVEL_START already defined" (#26)
* Avoid "Warning: Constant LARAVEL_START already defined" * Update README.md * Static doesn't work like that * Update README.md * Update README.md * Update README.md * Update README.md
1 parent e91faa7 commit ccb4e85

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ APP_RUNTIME=Runtime\Laravel\Runtime
2424

2525
use Illuminate\Contracts\Http\Kernel;
2626

27+
define('LARAVEL_START', microtime(true));
28+
2729
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
2830

29-
return function () {
30-
define('LARAVEL_START', microtime(true));
31-
$app = require_once __DIR__ . '/../bootstrap/app.php';
31+
return function (): Kernel {
32+
static $app;
33+
34+
if (null === $app) {
35+
$app = require dirname(__DIR__).'/bootstrap/app.php';
36+
}
3237

3338
return $app->make(Kernel::class);
3439
};
@@ -41,13 +46,17 @@ return function () {
4146

4247
use Illuminate\Contracts\Console\Kernel;
4348

49+
define('LARAVEL_START', microtime(true));
50+
4451
require_once __DIR__.'/vendor/autoload_runtime.php';
4552

46-
return function () {
47-
define('LARAVEL_START', microtime(true));
48-
$app = require_once __DIR__.'/bootstrap/app.php';
53+
return function (): Kernel {
54+
static $app;
55+
56+
if (null === $app) {
57+
$app = require __DIR__.'/bootstrap/app.php';
58+
}
4959

5060
return $app->make(Kernel::class);
5161
};
52-
5362
```

0 commit comments

Comments
 (0)