separate runtime check to a function

This commit is contained in:
printempw 2016-12-17 19:52:22 +08:00
parent 2807c3ce6d
commit 94495614c3
3 changed files with 23 additions and 13 deletions

View File

@ -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");
}
}
}
}

View File

@ -11,8 +11,6 @@
|
*/
require __DIR__.'/autoload.php';
$app = require_once __DIR__.'/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

View File

@ -7,18 +7,13 @@
* @author printempw <h@prinzeugen.net>
*/
// 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';