1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 08:30:07 +01:00
This commit is contained in:
NasirNobin
2022-03-22 01:10:06 +06:00
parent ee6a17ea57
commit 794fbc0c57
3 changed files with 35 additions and 3 deletions

View File

@@ -298,6 +298,32 @@ function ($version) use ($resolvedPhpVersion) {
});
}
/**
* Get PHP binary path for a given version
*
* @param string $phpVersion
*
* @return string|bool
*/
public function getPhpBinaryPath($phpVersion)
{
if (file_exists(BREW_PREFIX . "/opt/$phpVersion/bin/php")) {
return BREW_PREFIX . "/opt/$phpVersion/bin/php";
}
$cellar = $this->cli->runAsUser("brew --cellar $phpVersion");
$details = json_decode($this->cli->runAsUser("brew info --json $phpVersion"));
$path = !empty($details[0]->linked_keg) ? $details[0]->linked_keg : $details[0]->installed[0]->version;
if (file_exists(trim($cellar).'/'.$path.'/bin/php')) {
return trim($cellar).'/'.$path.'/bin/php';
}
return "php";
}
/**
* Restart the linked PHP-FPM Homebrew service.
*

View File

@@ -555,10 +555,16 @@
/**
* List isolated sites.
*/
$app->command('isolated [--site=]', function ($site) {
$app->command('isolated [--site=] [--binary]', function ($site, $binary) {
if ($site) {
if ($phpVersion = Site::customPhpVersion($site.'.'.data_get(Configuration::read(), 'tld'))) {
$phpVersion = PhpFpm::normalizePhpVersion($phpVersion);
if($binary){
return output(Brew::getPhpBinaryPath($phpVersion));
}
return output($phpVersion);
}
} else {