mirror of
https://github.com/laravel/valet.git
synced 2026-02-06 00:40:06 +01:00
Detect running php when no version constraint specified with use command
Fixes #756 Previously if `php` was installed as just `php` (the default Homebrew alias), Valet would not detect *which* PHP version was actually installed, and therefore `valet use` might do incorrect or unnecessary installations/links/etc. NOTE: This does NOT "convert" existing `php` alias to a numbered version. It merely accepts it as-is, but notes its version in an attempt to avoid extra installations. *NOTE: Specifally tested with PHP 7.4 and 7.3. No promises about old 5.6, etc aliases.*
This commit is contained in:
@@ -384,15 +384,16 @@
|
||||
* Allow the user to change the version of php valet uses
|
||||
*/
|
||||
$app->command('use phpVersion', function ($phpVersion) {
|
||||
PhpFpm::stopRunning();
|
||||
PhpFpm::validateRequestedVersion($phpVersion);
|
||||
|
||||
PhpFpm::stopRunning();
|
||||
$newVersion = PhpFpm::useVersion($phpVersion);
|
||||
|
||||
Nginx::restart();
|
||||
info(sprintf('Valet is now using %s.', $newVersion));
|
||||
info(sprintf('Valet is now using %s.', $newVersion) . PHP_EOL);
|
||||
info('Note that you might need to run <comment>composer global update</comment> if your PHP version change affects the dependencies of global packages required by Composer.');
|
||||
})->descriptions('Change the version of PHP used by valet', [
|
||||
'phpVersion' => 'The PHP version you want to use, e.g php@7.2',
|
||||
'phpVersion' => 'The PHP version you want to use, e.g php@7.3',
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user