From e833782276e48406fde81ca1fa344e65f67703b7 Mon Sep 17 00:00:00 2001 From: Joel Butcher Date: Tue, 7 Feb 2023 11:44:27 +0000 Subject: [PATCH 1/2] add --phpVersion option to valet link command --- cli/app.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cli/app.php b/cli/app.php index 25078d2..431a7cb 100644 --- a/cli/app.php +++ b/cli/app.php @@ -175,7 +175,7 @@ function (ConsoleCommandEvent $event) { /** * Register a symbolic link with Valet. */ - $app->command('link [name] [--secure]', function (OutputInterface $output, $name, $secure) { + $app->command('link [name] [--secure] [--phpVersion=]', function (OutputInterface $output, $name, $secure, $phpVersion = null) { $linkPath = Site::link(getcwd(), $name = $name ?: basename(getcwd())); info('A ['.$name.'] symbolic link has been created in ['.$linkPath.'].'); @@ -183,7 +183,18 @@ function (ConsoleCommandEvent $event) { if ($secure) { $this->runCommand('secure '.$name); } - })->descriptions('Link the current working directory to Valet'); + + if ($phpVersion) { + $this->runCommand(sprintf( + 'isolate php@%s --site=%s', + $phpVersion, + $name + )); + } + })->descriptions('Link the current working directory to Valet', [ + '--secure' => 'Link the site with a trusted TLS certificate', + '--phpVersion' => 'The PHP version you want to use to serve the site; e.g 8.1', + ]); /** * Display all of the registered symbolic links. @@ -559,7 +570,7 @@ function (ConsoleCommandEvent $event) { PhpFpm::useVersion($phpVersion, $force); })->descriptions('Change the version of PHP used by Valet', [ - 'phpVersion' => 'The PHP version you want to use, e.g php@7.3', + 'phpVersion' => 'The PHP version you want to use, e.g php@8.1', ]); /** From a6d163e16ece4c7a3dc803ce6afb1c2cc1300f84 Mon Sep 17 00:00:00 2001 From: Joel Butcher Date: Tue, 7 Feb 2023 12:05:54 +0000 Subject: [PATCH 2/2] update command --- cli/app.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cli/app.php b/cli/app.php index 431a7cb..38a9ce4 100644 --- a/cli/app.php +++ b/cli/app.php @@ -175,25 +175,25 @@ function (ConsoleCommandEvent $event) { /** * Register a symbolic link with Valet. */ - $app->command('link [name] [--secure] [--phpVersion=]', function (OutputInterface $output, $name, $secure, $phpVersion = null) { + $app->command('link [name] [--secure] [--isolate]', function (OutputInterface $output, $name, $secure, $isolate) { $linkPath = Site::link(getcwd(), $name = $name ?: basename(getcwd())); info('A ['.$name.'] symbolic link has been created in ['.$linkPath.'].'); if ($secure) { - $this->runCommand('secure '.$name); + $this->runCommand('secure'); } - if ($phpVersion) { - $this->runCommand(sprintf( - 'isolate php@%s --site=%s', - $phpVersion, - $name - )); + if ($isolate) { + if (Site::phpRcVersion($name)) { + $this->runCommand('isolate'); + } else { + warning('Valet could not determine which PHP version to use for this site.'); + } } })->descriptions('Link the current working directory to Valet', [ - '--secure' => 'Link the site with a trusted TLS certificate', - '--phpVersion' => 'The PHP version you want to use to serve the site; e.g 8.1', + '--secure' => 'Link the site with a trusted TLS certificate.', + '--isolate' => 'Isolate the site to the PHP version specified in the current working directory\'s .valetphprc file.', ]); /**