mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 00:20:08 +01:00
Drop need to pass sock to isolate command
This commit is contained in:
@@ -88,7 +88,7 @@ public function createConfigurationFiles($phpVersion = null)
|
||||
$contents = $this->files->get(__DIR__.'/../stubs/etc-phpfpm-valet.conf');
|
||||
$contents = str_replace(['VALET_USER', 'VALET_HOME_PATH'], [user(), VALET_HOME_PATH], $contents);
|
||||
if ($phpVersion) {
|
||||
$contents = str_replace('valet.sock', $this->fpmSockName($phpVersion), $contents);
|
||||
$contents = str_replace('valet.sock', self::fpmSockName($phpVersion), $contents);
|
||||
}
|
||||
$this->files->put($fpmConfigFile, $contents);
|
||||
|
||||
@@ -195,12 +195,14 @@ public function isolateDirectoryToVersion($directory, $version)
|
||||
throw new DomainException("The [{$directory}] site could not be found in Valet's site list.");
|
||||
}
|
||||
|
||||
$version = $this->validateRequestedVersion($version);
|
||||
|
||||
$this->brew->ensureInstalled($version, [], $this->taps);
|
||||
|
||||
$oldCustomPhpVersion = $this->site->customPhpVersion($site); // Example output: "74"
|
||||
$this->createConfigurationFiles($version);
|
||||
|
||||
$this->site->isolate($site, $this->fpmSockName($version), $version);
|
||||
$this->site->isolate($site, $version);
|
||||
|
||||
$this->stopIfUnused($oldCustomPhpVersion);
|
||||
$this->restart($version);
|
||||
@@ -342,7 +344,7 @@ public function validateRequestedVersion($version)
|
||||
* @param string|null $phpVersion
|
||||
* @return string
|
||||
*/
|
||||
public function fpmSockName($phpVersion = null)
|
||||
public static function fpmSockName($phpVersion = null)
|
||||
{
|
||||
$versionInteger = preg_replace('~[^\d]~', '', $phpVersion);
|
||||
|
||||
@@ -373,12 +375,12 @@ public function updateConfigurationForGlobalUpdate($newPhpVersion, $oldPhpVersio
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($content, $this->fpmSockName($newPhpVersion)) !== false) {
|
||||
if (strpos($content, self::fpmSockName($newPhpVersion)) !== false) {
|
||||
info(sprintf('Updating site %s to keep using version: %s', $file, $newPhpVersion));
|
||||
$this->files->put(VALET_HOME_PATH.'/Nginx/'.$file, str_replace($this->fpmSockName($newPhpVersion), 'valet.sock', $content));
|
||||
$this->files->put(VALET_HOME_PATH.'/Nginx/'.$file, str_replace(self::fpmSockName($newPhpVersion), 'valet.sock', $content));
|
||||
} elseif (strpos($content, 'valet.sock') !== false) {
|
||||
info(sprintf('Updating site %s to keep using version: %s', $file, $oldPhpVersion));
|
||||
$this->files->put(VALET_HOME_PATH.'/Nginx/'.$file, str_replace('valet.sock', $this->fpmSockName($oldPhpVersion), $content));
|
||||
$this->files->put(VALET_HOME_PATH.'/Nginx/'.$file, str_replace('valet.sock', self::fpmSockName($oldPhpVersion), $content));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -392,7 +394,7 @@ public function updateConfigurationForGlobalUpdate($newPhpVersion, $oldPhpVersio
|
||||
public function utilizedPhpVersions()
|
||||
{
|
||||
$fpmSockFiles = $this->brew->supportedPhpVersions()->map(function ($version) {
|
||||
return $this->fpmSockName($this->normalizePhpVersion($version));
|
||||
return self::fpmSockName($this->normalizePhpVersion($version));
|
||||
})->unique();
|
||||
|
||||
return collect($this->files->scandir(VALET_HOME_PATH.'/Nginx'))
|
||||
|
||||
@@ -697,15 +697,17 @@ public function buildSecureNginxServer($url, $siteConf = null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Nginx server configuration for the given Valet site.
|
||||
* Create new nginx config or modify existing nginx config to isolate this site
|
||||
* to a custom version of PHP.
|
||||
*
|
||||
* @param string $valetSite
|
||||
* @param string $fpmSockName
|
||||
* @param string $phpVersion
|
||||
* @return void
|
||||
*/
|
||||
public function isolate($valetSite, $fpmSockName, $phpVersion)
|
||||
public function isolate($valetSite, $phpVersion)
|
||||
{
|
||||
$fpmSockName = PhpFpm::fpmSockName($phpVersion);
|
||||
|
||||
if ($this->files->exists($this->nginxPath($valetSite))) {
|
||||
// Modify the existing config if it exists (likely because it's secured)
|
||||
$siteConf = $this->files->get($this->nginxPath($valetSite));
|
||||
@@ -769,7 +771,7 @@ public function unsecure($url)
|
||||
|
||||
// If the user had isolated the PHP version for this site, swap out .sock file
|
||||
if ($phpVersion) {
|
||||
$this->isolate($url, "valet{$phpVersion}.sock", $phpVersion);
|
||||
$this->isolate($url, $phpVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user