From 592354877d080f9424a8b4bb7d62ec75d8906798 Mon Sep 17 00:00:00 2001 From: Matt Stauffer Date: Sat, 12 Mar 2022 22:28:25 -0500 Subject: [PATCH] Rename isolateDirectory --- cli/Valet/PhpFpm.php | 9 ++++++--- cli/valet.php | 2 +- tests/PhpFpmTest.php | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cli/Valet/PhpFpm.php b/cli/Valet/PhpFpm.php index 557fa6a..ec3cc2e 100644 --- a/cli/Valet/PhpFpm.php +++ b/cli/Valet/PhpFpm.php @@ -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. * diff --git a/cli/valet.php b/cli/valet.php index f279a1b..7679fa3 100755 --- a/cli/valet.php +++ b/cli/valet.php @@ -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', diff --git a/tests/PhpFpmTest.php b/tests/PhpFpmTest.php index 436672a..d169731 100644 --- a/tests/PhpFpmTest.php +++ b/tests/PhpFpmTest.php @@ -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')); } }