fix environment check

This commit is contained in:
Pig Fang 2020-07-13 10:26:06 +08:00
parent aea797869b
commit 5f6f84bb4c
No known key found for this signature in database
GPG Key ID: A8198F548DADA9E2
2 changed files with 22 additions and 0 deletions

View File

@ -1,5 +1,7 @@
<?php
use Illuminate\Encryption\Encrypter;
(function () {
function die_with_utf8_encoding($error)
{
@ -14,6 +16,17 @@
);
}
$envPath = __DIR__.'/../.env';
if (!file_exists($envPath)) {
copy(__DIR__.'/../.env.example', $envPath);
}
$envFile = file_get_contents($envPath);
if (preg_match('/APP_KEY\s*=\s*\n/', $envFile)) {
$key = 'base64:'.base64_encode(Encrypter::generateKey('AES-256-CBC'));
file_put_contents($envPath, preg_replace('/APP_KEY\s*=\s*/', 'APP_KEY='.$key."\n\n", $envFile));
}
if (!empty(ini_get('disable_functions'))) {
die_with_utf8_encoding(
'[Error] Please don\'t disable any functions, which is specified in "php.ini" file.<br>'.

View File

@ -16,6 +16,15 @@ define('LARAVEL_START', microtime(true));
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Environment Check
|--------------------------------------------------------------------------
*/
if (!file_exists(__DIR__.'/../storage/install.lock')) {
require __DIR__.'/../bootstrap/chkenv.php';
}
/*
|--------------------------------------------------------------------------
| Turn On The Lights