currentStep(); $maxStep = $update->maxStep(); if (!$update->canAccessStep($currentStep)) { $update->gotoStep(1); } $error = $copy = ''; $pass = true; //step 1 if ($currentStep == 1) { $requirements = $update->listRequirementTableRows(); $pass = $requirements['pass']; if ($isPost) { $update->nextStep(); } } if ($currentStep == 2) { $tableRows = []; $versionTable = $versions = []; $tableRows[] = [ 'checkbox' => sprintf(''), 'tag_name' => 'Manual', 'name' => 'If there are changes that are not suitable for full coverage, please check this box and make sure you have updated the code manually', 'published_at' => '---', ]; try { //Unnecessary // $versions = $update->listVersions(); $versions = []; } catch (\Exception $exception) { $update->doLog("can not fetch versions from github: " . $exception->getMessage()); } if (!$isPost) { $versionHeader = [ 'checkbox' => 'Check', 'tag_name' => 'Version(tag)', 'name' => 'Description', 'published_at' => 'Release at', ]; try { $timezone = nexus_env('TIMEZONE'); } catch (\Exception $exception) { $update->doLog("no .env file, release time is github original"); $timezone = null; } try { $latestCommit = $update->getLatestCommit(); $time = \Carbon\Carbon::parse($latestCommit['commit']['committer']['date']); if ($timezone) { $time->tz = $timezone; } $tableRows[] = [ 'checkbox' => sprintf('', $latestCommit['sha']), 'tag_name' => 'Latest development code', 'name' => "Development testing only! Latest commit:" . $latestCommit['commit']['message'], 'published_at' => $time->format('Y-m-d H:i:s'), ]; } catch (\Exception $exception) { $update->doLog("can not fetch latest commit from github: " . $exception->getMessage()); } foreach ($versions as $version) { if ($version['draft']) { continue; } $time = \Carbon\Carbon::parse($version['published_at']); if ($timezone) { $time->tz = $timezone; } $versionUrl = $version['tag_name'] . '|' . $version['tarball_url']; $checked = !empty($_REQUEST['version_url']) && $_REQUEST['version_url'] == $versionUrl ? ' checked' : ''; $tableRows[] = [ 'checkbox' => sprintf('', $versionUrl, $checked), 'tag_name' => $version['tag_name'], 'name' => $version['name'], 'published_at' => $time->format('Y-m-d H:i:s'), ]; } } // dd($tableRows); while ($isPost) { try { if (empty($_REQUEST['version_url'])) { throw new \RuntimeException("No version selected yet"); } $downloadUrl = ''; if ($_REQUEST['version_url'] == 'manual') { $update->nextStep(); } elseif (\Illuminate\Support\Str::startsWith($_REQUEST['version_url'], 'development')) { $downloadUrlArr = explode('|', $_REQUEST['version_url']); $downloadUrl = sprintf('https://github.com/xiaomlove/nexusphp/archive/%s.zip', $downloadUrlArr[1]); } else { $versionUrlArr = explode('|', $_REQUEST['version_url']); $version = strtolower($versionUrlArr[0]); $downloadUrl = $versionUrlArr[1]; if (\Illuminate\Support\Str::startsWith($version, 'v')) { $version = substr($version, 1); } $update->doLog("version: $version, downloadUrl: $downloadUrl, currentVersion: " . VERSION_NUMBER); if (version_compare($version, VERSION_NUMBER, '<=')) { throw new \RuntimeException("Must select a version higher than the current one(" . VERSION_NUMBER . ")"); } } $update->downAndExtractCode($downloadUrl); $update->nextStep(); } catch (\Exception $exception) { $update->doLog($exception->getMessage() . $exception->getTraceAsString()); $error = $exception->getMessage(); break; } break; } } if ($currentStep == 3) { $envExampleFile = $rootpath . ".env.example"; $envExampleData = readEnvFile($envExampleFile); $envFormControls = $update->listEnvFormControls(); $newData = array_column($envFormControls, 'value', 'name'); while ($isPost) { try { $update->createEnvFile($_POST, 'update'); $update->nextStep(); } catch (\Exception $exception) { $error = $exception->getMessage(); break; } break; } $tableRows = [ [ 'label' => basename($envExampleFile), 'required' => 'exists && readable', 'current' => $envExampleFile, 'result' => $update->yesOrNo(file_exists($envExampleFile) && is_readable($envExampleFile)), ], ]; $fails = array_filter($tableRows, function ($value) {return $value['result'] == 'NO';}); $pass = empty($fails); } if ($currentStep == 4) { $settingTableRows = $update->listSettingTableRows(); $settings = $settingTableRows['settings']; $symbolicLinks = $settingTableRows['symbolic_links']; $tableRows = $settingTableRows['table_rows']; $pass = $settingTableRows['pass']; $mysqlInfo = $update->getMysqlVersionInfo(); $redisInfo = $update->getREdisVersionInfo(); while ($isPost) { set_time_limit(300); try { // $update->updateDependencies(); $update->createSymbolicLinks($symbolicLinks); $update->saveSettings($settings); $update->runExtraQueries(); $update->runMigrate(); $update->runExtraMigrate(); $update->nextStep(); } catch (\Exception $e) { $error = $e->getMessage(); break; } break; } } if ( !empty($error) || (isset($mysqlInfo) && !$mysqlInfo['match']) || (isset($redisInfo) && !$redisInfo['match']) ) { $pass = false; } ?> Update NexusPHP | step <?php echo $currentStep?>
renderSteps()?>
'; $header = [ 'label' => 'Item', 'required' => 'Require', 'current'=> 'Current', 'result'=> 'Result' ]; if ($currentStep == 1) { echo $update->renderTable($header, $requirements['table_rows']); } elseif ($currentStep == 3) { echo $update->renderTable($header, $tableRows); echo '
Before the next step, make sure that you have executed composer install in the root directory to update the dependencies.
'; echo $update->renderForm($envFormControls); } elseif ($currentStep == 2) { if (empty($tableRows)) { echo '
Sorry, there is no version to choose from at this time!
'; } else { echo $update->renderTable($versionHeader, $tableRows); } } elseif ($currentStep == 4) { echo $update->renderTable($header, $tableRows); echo '
'; echo sprintf('This step will merge %s to %s, then insert into database.', $tableRows[1]['label'], $tableRows[0]['label']); echo sprintf('
网页升级容易超时,强烈建议通过执行命令完成最后一步(如果是从1.5版本升级,务必这样做)
进入:%s,执行:php artisan nexus:update
', $rootpath); echo sprintf('
Web page upgrades tend to time out, it is highly recommended to complete the last step by executing the command (if upgrading from version 1.5, be sure to do so)
cd %s, and execute: php artisan nexus:update
', $rootpath); echo '
'; if (!$mysqlInfo['match']) { echo sprintf('
MySQL version: %s is too low, please use the newest version of 5.7 or above.
', $mysqlInfo['version']); } if (!$redisInfo['match']) { echo sprintf('
Redis version: %s is too low, please use 2.0.0 or above.
', $redisInfo['version']); } } elseif ($currentStep > $maxStep) { echo '
Congratulations, everything is ready!
'; echo '
For questions, consult the upgrade log at: ' . $update->getLogFile() . '
'; echo '
For security reasons, please delete the following directories
'; echo '
' . $update->getUpdateDirectory() . '
'; $update->setLock(); } echo'
'; if (!empty($error)) { echo sprintf('
Error: %s
', nl2br($error)); unset($error); } if (!empty($copy)) { echo sprintf('
', $copy); unset($copy); } ?>
Go to homepage
Welcome to the NexusPHP updater, if you have any questions, clickherefor help.