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

Rename isolateDirectory

This commit is contained in:
Matt Stauffer
2022-03-12 22:28:25 -05:00
parent 79da3e1c28
commit 592354877d
3 changed files with 9 additions and 6 deletions

View File

@@ -71,6 +71,7 @@ public function uninstall()
/**
* Create (or re-create) the PHP FPM configuration files.
*
* Writes FPM config file, pointing to the correct .sock file, and log and ini files.
*
* @param string|null $phpVersion
@@ -183,13 +184,13 @@ public function stopIfUnused($phpVersion = null)
}
/**
* Isolate a given directory to use a specific version of php.
* Isolate a given directory to use a specific version of PHP.
*
* @param string $directory
* @param string $version
* @return void
*/
public function isolateDirectoryToVersion($directory, $version)
public function isolateDirectory($directory, $version)
{
if (! $site = $this->site->getSiteUrl($directory)) {
throw new DomainException("The [{$directory}] site could not be found in Valet's site list.");
@@ -200,6 +201,7 @@ public function isolateDirectoryToVersion($directory, $version)
$this->brew->ensureInstalled($version, [], $this->taps);
$oldCustomPhpVersion = $this->site->customPhpVersion($site); // Example output: "74"
$this->cli->quietly('sudo rm '.VALET_HOME_PATH.'/'.$this->fpmSockName($oldCustomPhpVersion));
$this->createConfigurationFiles($version);
$this->site->isolate($site, $version);
@@ -298,7 +300,6 @@ public function useVersion($version, $force = false)
*/
public function normalizePhpVersion($version)
{
// @todo There's probably a way to incorporate this into the regex
if (strpos($version, 'php') === false) {
$version = 'php'.$version;
}
@@ -348,8 +349,10 @@ public static function fpmSockName($phpVersion = null)
/**
* Update all existing Nginx files when running a global PHP version update.
*
* If a given file is pointing to `valet.sock`, it's targeting the old global PHP version;
* update it to point to the new custom sock file for that version.
*
* 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.
*

View File

@@ -519,7 +519,7 @@
* Allow the user to change the version of php valet uses to serve a given site.
*/
$app->command('isolate [site] [phpVersion] ', function ($site, $phpVersion) {
PhpFpm::isolateDirectoryToVersion($site, $phpVersion);
PhpFpm::isolateDirectory($site, $phpVersion);
})->descriptions('Change the version of PHP used by valet to serve a given site', [
'site' => 'The valet site (e.g. site.test) you want to isolate to a given PHP version',
'phpVersion' => 'The PHP version you want to use, e.g php@7.3',

View File

@@ -386,7 +386,7 @@ public function test_isolate_will_isolate_a_site()
$phpFpmMock->shouldNotReceive('install');
$phpFpmMock->shouldNotReceive('updateConfigurationForGlobalUpdate');
$this->assertSame(null, $phpFpmMock->isolateDirectoryToVersion('test', 'php@7.2'));
$this->assertSame(null, $phpFpmMock->isolateDirectory('test', 'php@7.2'));
}
public function test_un_isolate_can_remove_isolation_for_a_site()
@@ -430,7 +430,7 @@ public function test_isolate_will_throw_if_site_is_not_parked_or_linked()
$siteMock->shouldReceive('getSiteUrl');
$this->assertSame(null, $phpFpmMock->isolateDirectoryToVersion('test', 'php@8.1'));
$this->assertSame(null, $phpFpmMock->isolateDirectory('test', 'php@8.1'));
}
}