88
99class Brew
1010{
11+ // This is the array of PHP versions that Valet will attempt to install/configure when requested
1112 const SUPPORTED_PHP_VERSIONS = [
1213 'php ' ,
1314@@ -19,9 +20,22 @@ class Brew
19202021 ];
2122
22- const BREW_DISABLE_AUTO_CLEANUP = 'HOMEBREW_NO_INSTALL_CLEANUP=1 ' ;
23+ // Update this LATEST and the following LIMITED array when PHP versions are released or retired
24+ // We specify a numbered version here even though Homebrew links its generic 'php' alias to it
25+ const LATEST_PHP_VERSION =
'[email protected] ' ;
2326
24- const LATEST_PHP_VERSION =
'[email protected] ' ;
27+ // These are the PHP versions that should be installed via the shivammathur/php tap because
28+ // Homebrew officially no longer bottles them or they're marked disabled in their formula
29+ // Cue: Homebrew reports "[email protected] has been disabled because it is a versioned formula" 30+ const LIMITED_PHP_VERSIONS = [
31+ 32+ 33+ 34+ 35+ 36+ ];
37+
38+ const BREW_DISABLE_AUTO_CLEANUP = 'HOMEBREW_NO_INSTALL_CLEANUP=1 ' ;
2539
2640 public function __construct (public CommandLine $ cli , public Filesystem $ files )
2741 {
@@ -72,6 +86,14 @@ public function supportedPhpVersions(): Collection
7286 return collect (static ::SUPPORTED_PHP_VERSIONS );
7387 }
7488
89+ /**
90+ * Get a list of disabled/limited PHP versions.
91+ */
92+ public function limitedPhpVersions (): Collection
93+ {
94+ return collect (static ::LIMITED_PHP_VERSIONS );
95+ }
96+
7597 /**
7698 * Get a list of installed PHP formulae.
7799 */
@@ -135,7 +157,9 @@ public function installOrFail(string $formula, array $options = [], array $taps
135157 }
136158
137159 output ('<info>[ ' .$ formula .'] is not installed, installing it now via Brew...</info> 🍻 ' );
138- if ($ formula !== 'php ' && starts_with ($ formula , 'php ' ) && preg_replace ('/[^\d]/ ' , '' , $ formula ) < '73 ' ) {
160+
161+ if ($ this ->limitedPhpVersions ()->contains ($ formula )) {
162+ $ formula = 'shivammathur/php/ ' . $ formula ;
139163 warning ('Note: older PHP versions may take 10+ minutes to compile from source. Please wait ... ' );
140164 }
141165
0 commit comments