diff --git a/app/helpers.php b/app/helpers.php index c877177a..e715f2ab 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -300,3 +300,20 @@ if (! function_exists('delete_sessions')) { Session::save(); } } + +if (! function_exists('runtime_check')) { + + function runtime_check(array $requirements) + { + // check php version + if (version_compare(PHP_VERSION, $requirements['php'], '<')) { + exit("[Error] Blessing Skin Server needs PHP version >= {$requirements['php']}, you are now using ".PHP_VERSION); + } + + foreach ($requirements['extensions'] as $extension) { + if (!extension_loaded($extension)) { + exit("[Error] You have not installed the $extension extension"); + } + } + } +} diff --git a/bootstrap/handler.php b/bootstrap/handler.php index 751adb7a..086945f0 100644 --- a/bootstrap/handler.php +++ b/bootstrap/handler.php @@ -11,8 +11,6 @@ | */ -require __DIR__.'/autoload.php'; - $app = require_once __DIR__.'/app.php'; $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); diff --git a/index.php b/index.php index 5c7a1f2f..1de66879 100755 --- a/index.php +++ b/index.php @@ -7,18 +7,13 @@ * @author printempw */ -// runtime check -if (version_compare(PHP_VERSION, '5.5.9', '<')) { - exit('[Error] Blessing Skin Server needs PHP version >= 5.5.9, you are now using '.PHP_VERSION); -} +require __DIR__.'/bootstrap/autoload.php'; -if (!class_exists('PDO')) { - exit('[Error] You have not installed the PDO extension'); -} - -if (!function_exists('openssl_encrypt')) { - exit('[Error] You have not installed the OpenSSL extension'); -} +// check the runtime environment +runtime_check([ + 'php' => '5.5.9', + 'extensions' => ['pdo_mysql', 'openssl', 'gd'] +]); // handle the request require __DIR__.'/bootstrap/handler.php';