mirror of
https://github.com/laravel/valet.git
synced 2026-02-06 00:40:06 +01:00
add tests for use version and return the found version to output
This commit is contained in:
committed by
Matt Stauffer
parent
6158e5129b
commit
6a5c06e934
@@ -137,6 +137,7 @@ function stopRunning()
|
||||
* Use a specific version of php
|
||||
*
|
||||
* @param $version
|
||||
* @return string
|
||||
*/
|
||||
function useVersion($version)
|
||||
{
|
||||
@@ -147,18 +148,18 @@ function useVersion($version)
|
||||
|
||||
info(sprintf('Finding brew formula for: %s', $version));
|
||||
$foundVersion = $this->brew->search($version)
|
||||
->filter(function ($service) {
|
||||
->first(function ($service) {
|
||||
return $this->brew->supportedPhpVersions()->contains($service);
|
||||
})
|
||||
->first();
|
||||
info(sprintf('Found brew formula: %s', $foundVersion));
|
||||
});
|
||||
|
||||
if (!$this->brew->supportedPhpVersions()->contains($foundVersion)) {
|
||||
if (is_null($foundVersion)) {
|
||||
throw new DomainException(
|
||||
sprintf('Valet doesn\'t support PHP version: %s', $foundVersion)
|
||||
sprintf('Valet can\'t find a supported version of PHP for: %s', $version)
|
||||
);
|
||||
}
|
||||
|
||||
info(sprintf('Found brew formula: %s', $foundVersion));
|
||||
|
||||
if ($this->brew->hasLinkedPhp()) {
|
||||
$currentVersion = $this->brew->linkedPhp();
|
||||
info(sprintf('Unlinking current version: %s', $currentVersion));
|
||||
@@ -171,5 +172,7 @@ function useVersion($version)
|
||||
$this->brew->link($foundVersion, true);
|
||||
|
||||
$this->install();
|
||||
|
||||
return $foundVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,10 +282,10 @@
|
||||
$app->command('use phpVersion', function ($phpVersion) {
|
||||
PhpFpm::stopRunning();
|
||||
|
||||
PhpFpm::useVersion($phpVersion);
|
||||
$newVersion = PhpFpm::useVersion($phpVersion);
|
||||
|
||||
Nginx::restart();
|
||||
info(sprintf('Valet is now using %s.', $phpVersion));
|
||||
info(sprintf('Valet is now using %s.', $newVersion));
|
||||
})->descriptions('Change the version of php used by valet', [
|
||||
'phpVersion' => 'The PHP version you want to use, e.g php@7.2',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user