1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 08:30:07 +01:00

Apply refactor & cleanup from the code review

This commit is contained in:
Nasir Uddin Nobin
2022-02-15 16:44:29 +06:00
committed by GitHub
parent 794e366ba5
commit 5c1043776e
4 changed files with 128 additions and 91 deletions

View File

@@ -509,45 +509,7 @@
}
}
if ($site) {
$tld = Configuration::read()['tld'];
if ($site == '.') { // Allow user to use dot as current dir's site `--site=.`
$site = Site::host(getcwd()).'.'.$tld;
}
if (false === strpos($site, '.'.$tld)) {
$site = $site.'.'.$tld; // Allow user to pass just the site's directory name
}
if (! Site::isValidSite($site)) {
return warning(sprintf('Site %s could not be found in valet site list.', $site));
}
if ($phpVersion == 'default') {
$customPhpVersion = Site::customPhpVersion($site); // Example output: "74"
Site::removeIsolation($site);
if ($customPhpVersion) {
PhpFpm::maybeStop('php'.$customPhpVersion);
}
Nginx::restart();
info(sprintf('The [%s] site is now using default php version.', $site));
} else {
$newVersion = PhpFpm::useVersion($phpVersion, $force, $site);
Site::installSiteConfig($site, PhpFpm::fpmSockName($phpVersion), $phpVersion);
Nginx::restart();
info(sprintf('The [%s] site is now using %s.', $site, $newVersion));
}
} else {
$newVersion = PhpFpm::useVersion($phpVersion, $force);
Nginx::restart();
info(sprintf('Valet is now using %s.', $newVersion).PHP_EOL);
info('Note that you might need to run <comment>composer global update</comment> if your PHP version change affects the dependencies of global packages required by Composer.');
}
PhpFpm::useVersion($phpVersion, $force, $site);
})->descriptions('Change the version of PHP used by valet', [
'phpVersion' => 'The PHP version you want to use, e.g php@7.3',
'--site' => 'Isolate PHP version of a specific valet site. e.g: --site=site.test',