Make printout more consistent

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2022-05-24 19:36:01 -07:00
parent b67ed3eac2
commit 43e97ea6ea

View file

@ -43,6 +43,8 @@ echo "--------------------------------------------------------\n\n";
// Check the .env looks ok // Check the .env looks ok
$env = file('.env'); $env = file('.env');
$env_error_count = 0; $env_error_count = 0;
$env_good = '';
$env_bad = '';
// Loop through each line of the .env // Loop through each line of the .env
foreach ($env as $line_num => $line) { foreach ($env as $line_num => $line) {
@ -51,14 +53,16 @@ foreach ($env as $line_num => $line) {
list ($env_key, $env_value) = $env_line = explode('=', $line); list ($env_key, $env_value) = $env_line = explode('=', $line);
// The array starts at 0
$show_line_num = $line_num+1;
$env_value = trim($env_value); $env_value = trim($env_value);
if ($env_key == 'APP_KEY') { if ($env_key == 'APP_KEY') {
if (($env_value=='') || (strlen($env_value) < 20)) { if (($env_value=='') || (strlen($env_value) < 20)) {
echo "✘ APP_KEY ERROR in your .env: Your APP_KEY should not be blank. Run php artisan key:generate to generate one."; $env_bad .= "✘ APP_KEY ERROR in your .env on line #'.$show_line_num.': Your APP_KEY should not be blank. Run `php artisan key:generate` to generate one.\n";
$env_error_count++;
} else { } else {
echo "√ Your APP_KEY is not blank. \n"; $env_good .= "√ Your APP_KEY is not blank. \n";
} }
} }
@ -67,26 +71,23 @@ foreach ($env as $line_num => $line) {
$app_url_length = strlen($env_value); $app_url_length = strlen($env_value);
if (($env_value!="null") && ($env_value!="")) { if (($env_value!="null") && ($env_value!="")) {
echo '√ Your APP_URL is not null or blank. It is set to '.$env_value."\n"; $env_good .= '√ Your APP_URL is not null or blank. It is set to '.$env_value."\n";
if (!str_begins(trim($env_value), 'http://') && (!str_begins($env_value, 'https://'))) { if (!str_begins(trim($env_value), 'http://') && (!str_begins($env_value, 'https://'))) {
echo '✘ APP_URL ERROR in your .env on line #'.$line_num.' of your .env: Your APP_URL should start with https:// or http://!! It is currently set to: '.$env_value; $env_bad .= '✘ APP_URL ERROR in your .env on line #'.$show_line_num.': Your APP_URL should start with https:// or http://!! It is currently set to: '.$env_value;
$env_error_count++;
} else { } else {
echo '√ Your APP_URL is set to '.$env_value.' and starts with the protocol (https:// or http://)'."\n"; $env_good .= '√ Your APP_URL is set to '.$env_value.' and starts with the protocol (https:// or http://)'."\n";
} }
if (str_ends(trim($env_value), "/")) { if (str_ends(trim($env_value), "/")) {
echo '✘ APP_URL ERROR in your .env on line #'.$line_num.' of your .env: Your APP_URL should NOT end with a trailing slash. It is currently set to: '.$env_value; $env_bad .= '✘ APP_URL ERROR in your .env on line #'.$show_line_num.': Your APP_URL should NOT end with a trailing slash. It is currently set to: '.$env_value;
$env_error_count++;
} else { } else {
echo '√ Your APP_URL ('.$env_value.') does not have a trailing slash.'."\n"; $env_good .= '√ Your APP_URL ('.$env_value.') does not have a trailing slash.'."\n";
} }
} else { } else {
echo "✘ APP_URL ERROR in your .env on line #".$line_num.": Your APP_URL CANNOT be set to null or left blank.\n"; $env_bad .= "✘ APP_URL ERROR in your .env on line #".$show_line_num.": Your APP_URL CANNOT be set to null or left blank.\n";
$env_error_count++;
} }
} }
@ -96,16 +97,22 @@ foreach ($env as $line_num => $line) {
} }
if ($env_error_count > 0) { echo $env_good;
echo "\n\n--------------------- !! ERROR !! ----------------------\n";
if ($env_bad !='') {
echo "\n--------------------- !! ERROR !! ----------------------\n";
echo "Your .env file is misconfigured. Upgrade cannot continue.\n"; echo "Your .env file is misconfigured. Upgrade cannot continue.\n";
echo "------------------------- :( ---------------------------\n"; echo "--------------------------------------------------------\n\n";
echo $env_bad;
echo "\n\n--------------------------------------------------------\n";
echo "ABORTING THE INSTALLER \n"; echo "ABORTING THE INSTALLER \n";
echo "Please correct the issues above in ".getcwd()."/.env and try again.\n"; echo "Please correct the issues above in ".getcwd()."/.env and try again.\n";
echo "------------------------- :( ---------------------------\n"; echo "--------------------------------------------------------\n";
exit; exit;
} }
echo "--------------------------------------------------------\n"; echo "--------------------------------------------------------\n";
echo "STEP 2: Checking PHP requirements: \n"; echo "STEP 2: Checking PHP requirements: \n";
echo "--------------------------------------------------------\n\n"; echo "--------------------------------------------------------\n\n";
@ -198,10 +205,10 @@ if ($ext_missing!='') {
echo "--------------------- !! ERROR !! ----------------------\n"; echo "--------------------- !! ERROR !! ----------------------\n";
echo $ext_missing; echo $ext_missing;
echo "------------------------- :( ---------------------------\n"; echo "--------------------------------------------------------\n";
echo "ABORTING THE INSTALLER \n"; echo "ABORTING THE INSTALLER \n";
echo "Please install the extensions above and re-run this script.\n"; echo "Please install the extensions above and re-run this script.\n";
echo "------------------------- :( ---------------------------\n"; echo "--------------------------------------------------------\n";
exit; exit;
} else { } else {
echo $ext_installed."\n"; echo $ext_installed."\n";