diff --git a/upgrade.php b/upgrade.php index 92d75f3a28..89c00a4981 100644 --- a/upgrade.php +++ b/upgrade.php @@ -15,6 +15,7 @@ if ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') || (!function_exists('posix_get } +$app_environment = 'develop'; // Check if a branch or tag was passed in the command line, // otherwise just use master @@ -58,6 +59,26 @@ foreach ($env as $line_num => $line) { $env_value = trim($env_value); + + /** + * We set this $app_environment here to determine which version of composer to use, --no-dev or with dev dependencies. + * This doesn't actually *change* anything in the .env file, but if the user is running this with + * APP_ENV set to anything OTHER than production, they'll get an error when they try to dump-autoload + * because the Dusk service provider only tries to load if the app is not in production mode. + * + * It's 100% okay if they're not in production mode, but this will avoid any confusion as they get + * erroneous errors using this upgrader if they are not in production mode when they run this script. + * + * We use this further down in the composer section of this upgrader. + */ + + if ($env_key == "APP_ENV") { + if ($env_value == 'production') { + $app_environment = 'production'; + } + } + + if ($env_key == 'APP_KEY') { if (($env_value=='') || (strlen($env_value) < 20)) { $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"; @@ -354,12 +375,26 @@ if (file_exists('composer.phar')) { echo $composer_update."\n\n"; $composer_dump = shell_exec('php composer.phar dump'); - $composer = shell_exec('php composer.phar install --no-dev --prefer-source'); + + // Use --no-dev only if we are in production mode. + // This will cause errors otherwise, if the user is in develop or local for their APP_ENV + if ($app_environment == 'production') { + $composer = shell_exec('php composer.phar install --no-dev --prefer-source'); + } else { + $composer = shell_exec('php composer.phar install --prefer-source'); + } } else { + echo "-- We couldn't find a local composer.phar. No worries, trying globally.\n\n"; $composer_dump = shell_exec('composer dump'); - $composer = shell_exec('composer install --no-dev --prefer-source'); + + if ($app_environment == 'production') { + $composer = shell_exec('composer install --no-dev --prefer-source'); + } else { + $composer = shell_exec('composer install --prefer-source'); + } + } echo $composer_dump."\n";