mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 16:40:05 +01:00
Stop unused PHP versions
This commit is contained in:
@@ -178,6 +178,21 @@ public function stopRunning()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop PHP, if a specific version isn't being used globally or by any sites.
|
||||
*
|
||||
* @param string $phpVersion
|
||||
* @return void
|
||||
*/
|
||||
public function maybeStop($phpVersion)
|
||||
{
|
||||
$phpVersion = $this->normalizePhpVersion($phpVersion);
|
||||
|
||||
if(! in_array($phpVersion, $this->utilizedPhpVersions())) {
|
||||
$this->brew->stopService($phpVersion);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a specific version of php.
|
||||
*
|
||||
@@ -305,8 +320,8 @@ public function fpmSockName($phpVersion = null)
|
||||
* If a given file is pointing the custom sock file for the new global version, that new
|
||||
* version will now be hosted at `valet.sock`, so update the config file to point to that instead.
|
||||
*
|
||||
* @param $newPhpVersion
|
||||
* @param $oldPhpVersion
|
||||
* @param string $newPhpVersion
|
||||
* @param string $oldPhpVersion
|
||||
* @return void
|
||||
*/
|
||||
public function updateConfigurationForGlobalUpdate($newPhpVersion, $oldPhpVersion)
|
||||
|
||||
@@ -712,12 +712,12 @@ public function installSiteConfig($valetSite, $fpmSockName, $phpVersion)
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove PHP Version isolation from a specific site
|
||||
* Remove PHP Version isolation from a specific site.
|
||||
*
|
||||
* @param string $valetSite
|
||||
* @return void
|
||||
*/
|
||||
function removeIsolation($valetSite)
|
||||
public function removeIsolation($valetSite)
|
||||
{
|
||||
// When site has SSL certificate, just re-generate the nginx config.
|
||||
// It will be using the `valet.sock` by default from now
|
||||
@@ -1075,7 +1075,7 @@ public function customPhpVersion($url)
|
||||
if (starts_with($siteConf, '# Valet isolated PHP version')) {
|
||||
$firstLine = explode(PHP_EOL, $siteConf)[0];
|
||||
|
||||
return preg_replace("/[^\d]*/", '', $firstLine);
|
||||
return preg_replace("/[^\d]*/", '', $firstLine); // Example output: "74" or "81"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +525,12 @@
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user