1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-04 16:10:08 +01:00
This commit is contained in:
NasirNobin
2022-03-22 01:47:37 +06:00
parent 794fbc0c57
commit 3d85b44e6a
2 changed files with 24 additions and 3 deletions

View File

@@ -304,12 +304,14 @@ function ($version) use ($resolvedPhpVersion) {
*
* @param string $phpVersion
*
* @return string|bool
* @return string
*/
public function getPhpBinaryPath($phpVersion)
{
if (file_exists(BREW_PREFIX . "/opt/$phpVersion/bin/php")) {
return BREW_PREFIX . "/opt/$phpVersion/bin/php";
$versionInteger = preg_replace('~[^\d]~', '', $phpVersion);
if (file_exists(BREW_PREFIX . "/bin/valetphp{$versionInteger}")) {
return BREW_PREFIX . "/bin/valetphp{$versionInteger}";
}
$cellar = $this->cli->runAsUser("brew --cellar $phpVersion");
@@ -321,9 +323,27 @@ public function getPhpBinaryPath($phpVersion)
return trim($cellar).'/'.$path.'/bin/php';
}
if (file_exists(BREW_PREFIX . "/opt/$phpVersion/bin/php")) {
return BREW_PREFIX . "/opt/$phpVersion/bin/php";
}
return "php";
}
/**
* Create a PHP binary symlink for a PHP version
*
* @param string $phpVersion
*
* @return void
*/
public function symlinkPhpBinary($phpVersion)
{
$versionInteger = preg_replace('~[^\d]~', '', $phpVersion);
$this->files->symlinkAsUser($this->getPhpBinaryPath($phpVersion), BREW_PREFIX . "/bin/valetphp{$versionInteger}");
}
/**
* Restart the linked PHP-FPM Homebrew service.
*

View File

@@ -221,6 +221,7 @@ public function isolateDirectory($directory, $version)
$this->createConfigurationFiles($version);
$this->site->isolate($site, $version);
$this->brew->symlinkPhpBinary($version);
$this->stopIfUnused($oldCustomPhpVersion);
$this->restart($version);