mirror of
https://github.com/laravel/valet.git
synced 2026-02-06 00:40:06 +01:00
Unify php versions list. Fix deprecated homebrew/php
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
|
||||
class Brew
|
||||
{
|
||||
const SUPPORTED_PHP_VERSIONS = ['php', 'php@7.2', 'php@7.1', 'php@7.0', 'php@5.6'];
|
||||
|
||||
var $cli, $files;
|
||||
|
||||
/**
|
||||
@@ -182,7 +184,9 @@ function linkedPhp()
|
||||
$resolvedPath = $this->files->readLink('/usr/local/bin/php');
|
||||
|
||||
return $this->supportedPhpVersions()->first(function ($version) use ($resolvedPath) {
|
||||
return strpos(preg_replace('/([@|\.])/', '', $resolvedPath), "/$version/") !== false;
|
||||
$resolvedPathNormalized= preg_replace('/([@|\.])/', '', $resolvedPath);
|
||||
$versionNormalized = preg_replace('/([@|\.])/', '', $version);
|
||||
return strpos($resolvedPathNormalized, "/$versionNormalized/") !== false;
|
||||
}, function () {
|
||||
throw new DomainException("Unable to determine linked PHP.");
|
||||
});
|
||||
|
||||
@@ -95,7 +95,10 @@ function restart()
|
||||
*/
|
||||
function stop()
|
||||
{
|
||||
$this->brew->stopService('php56', 'php70', 'php71', 'php72', 'php');
|
||||
call_user_func_array(
|
||||
[$this->brew, 'stopService'],
|
||||
Brew::SUPPORTED_PHP_VERSIONS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,13 +108,18 @@ function stop()
|
||||
*/
|
||||
function fpmConfigPath()
|
||||
{
|
||||
$confLookup = [
|
||||
'php' => '/usr/local/etc/php/7.2/php-fpm.d/www.conf',
|
||||
'php72' => '/usr/local/etc/php/7.2/php-fpm.d/www.conf',
|
||||
'php71' => '/usr/local/etc/php/7.1/php-fpm.d/www.conf',
|
||||
'php70' => '/usr/local/etc/php/7.0/php-fpm.d/www.conf',
|
||||
'php56' => '/usr/local/etc/php/5.6/php-fpm.conf',
|
||||
];
|
||||
$confLookup = [];
|
||||
|
||||
foreach (Brew::SUPPORTED_PHP_VERSIONS as $version) {
|
||||
$versionNormalized = preg_replace('/([^\d\.])/', '', $version);
|
||||
$versionNormalized = $versionNormalized === ''
|
||||
? '7.2'
|
||||
: $versionNormalized;
|
||||
|
||||
$confLookup[$version] = $versionNormalized === '5.6'
|
||||
? '/usr/local/etc/php/5.6/php-fpm.conf'
|
||||
: "/usr/local/etc/php/${versionNormalized}/php-fpm.d/www.conf";
|
||||
}
|
||||
|
||||
return $confLookup[$this->brew->linkedPhp()];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user