Skip to content

Commit 88b73fe

Browse files
committed
Added pre-install dependency check
1 parent ef23c56 commit 88b73fe

File tree

1 file changed

+60
-47
lines changed

1 file changed

+60
-47
lines changed

index.php

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,66 @@
33
use Illuminate\Contracts\Http\Kernel;
44
use Illuminate\Http\Request;
55

6-
define('LARAVEL_START', microtime(true));
6+
$installing_file_exists = file_exists(__DIR__ . '/INSTALLING');
77

8-
/*
9-
|--------------------------------------------------------------------------
10-
| Check If Application Is Under Maintenance
11-
|--------------------------------------------------------------------------
12-
|
13-
| If the application is maintenance / demo mode via the "down" command we
14-
| will require this file so that any prerendered template can be shown
15-
| instead of starting the framework, which could cause an exception.
16-
|
17-
*/
8+
if ($installing_file_exists) {
9+
$required_extensions = array('bcmath', 'ctype', 'curl', 'dom', 'fileinfo', 'json', 'mbstring', 'openssl', 'pcre', 'pdo', 'tokenizer', 'xml');
1810

19-
if (file_exists(__DIR__.'/storage/framework/maintenance.php')) {
20-
require __DIR__.'/storage/framework/maintenance.php';
11+
foreach ($required_extensions as $ext) {
12+
if (!extension_loaded($ext)) {
13+
throw new Exception('PHP extension ' . $ext . ' is not installed on your system');
14+
}
15+
}
2116
}
22-
23-
/*
24-
|--------------------------------------------------------------------------
25-
| Register The Auto Loader
26-
|--------------------------------------------------------------------------
27-
|
28-
| Composer provides a convenient, automatically generated class loader for
29-
| this application. We just need to utilize it! We'll simply require it
30-
| into the script here so we don't need to manually load our classes.
31-
|
32-
*/
33-
34-
require __DIR__.'/vendor/autoload.php';
35-
36-
/*
37-
|--------------------------------------------------------------------------
38-
| Run The Application
39-
|--------------------------------------------------------------------------
40-
|
41-
| Once we have the application, we can handle the incoming request using
42-
| the application's HTTP kernel. Then, we will send the response back
43-
| to this client's browser, allowing them to enjoy our application.
44-
|
45-
*/
46-
47-
$app = require_once __DIR__.'/bootstrap/app.php';
48-
49-
$kernel = $app->make(Kernel::class);
50-
51-
$response = tap($kernel->handle(
52-
$request = Request::capture()
53-
))->send();
54-
55-
$kernel->terminate($request, $response);
17+
18+
define('LARAVEL_START', microtime(true));
19+
20+
/*
21+
|--------------------------------------------------------------------------
22+
| Check If Application Is Under Maintenance
23+
|--------------------------------------------------------------------------
24+
|
25+
| If the application is maintenance / demo mode via the "down" command we
26+
| will require this file so that any prerendered template can be shown
27+
| instead of starting the framework, which could cause an exception.
28+
|
29+
*/
30+
31+
if (file_exists(__DIR__.'/storage/framework/maintenance.php')) {
32+
require __DIR__.'/storage/framework/maintenance.php';
33+
}
34+
35+
/*
36+
|--------------------------------------------------------------------------
37+
| Register The Auto Loader
38+
|--------------------------------------------------------------------------
39+
|
40+
| Composer provides a convenient, automatically generated class loader for
41+
| this application. We just need to utilize it! We'll simply require it
42+
| into the script here so we don't need to manually load our classes.
43+
|
44+
*/
45+
46+
require __DIR__.'/vendor/autoload.php';
47+
48+
/*
49+
|--------------------------------------------------------------------------
50+
| Run The Application
51+
|--------------------------------------------------------------------------
52+
|
53+
| Once we have the application, we can handle the incoming request using
54+
| the application's HTTP kernel. Then, we will send the response back
55+
| to this client's browser, allowing them to enjoy our application.
56+
|
57+
*/
58+
59+
$app = require_once __DIR__.'/bootstrap/app.php';
60+
61+
$kernel = $app->make(Kernel::class);
62+
63+
$response = tap($kernel->handle(
64+
$request = Request::capture()
65+
))->send();
66+
67+
$kernel->terminate($request, $response);
68+

0 commit comments

Comments
 (0)