Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install older PHP versions via alternate tap #1411

Merged
merged 1 commit into from
May 12, 2023

Conversation

drbyte
Copy link
Contributor

@drbyte drbyte commented May 3, 2023

Fixes #1407

Homebrew's support policy now aggressively disables older versions earlier than it did previously. That is why we tap the shivammathur/php repository.

But since Homebrew also now "keeps" those old formulae but marks them as disabled, when Valet runs brew install [email protected] it fails because Homebrew just aborts due to its flags in the outdated formula. (They mark it as "disabled" and/or "keg_only :versioned_formula".) To override that we must use brew install shivammathur/php/[email protected] internally.

Therefore, we need to maintain a list of which PHP Versions we wish to specifically prefix with the shivammathur/php tap in order to bypass Homebrew's flags.

ANNUAL MAINTENANCE

  1. This PR adds the array of LIMITED_PHP_VERSIONS which we will have to update annually when new PHP versions are retired as others are released.
  2. We should also annually update the LATEST_PHP_VERSION string.

@drbyte
Copy link
Contributor Author

drbyte commented May 3, 2023

Userland test results: #1407 (comment)

@@ -135,10 +145,14 @@ public function installOrFail(string $formula, array $options = [], array $taps
}

output('<info>['.$formula.'] is not installed, installing it now via Brew...</info> 🍻');
if ($formula !== 'php' && starts_with($formula, 'php') && preg_replace('/[^\d]/', '', $formula) < '73') {
if ($formula !== 'php' && starts_with($formula, 'php') && preg_replace('/[^\d]/', '', $formula) < '81') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we possibly move 81 here into a const so we can remember to check that regularly too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's just displaying an informational message, ima merge it with the newly-added array constant, since both are actually quite tightly linked. And it's harmless if it shows the message but was wrong, since instead of 10 minutes it'll be 10 seconds, and nobody will be offput by that 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test as well

@drbyte drbyte force-pushed the install-via-alt-tap branch from d1d2e1b to 92fe7a7 Compare May 5, 2023 23:33
Fixes laravel#1407

Homebrew's support policy now aggressively disables older versions earlier than it did previously.
That is why we tap the `shivammathur/php` repository.

But since Homebrew also now "keeps" those old formulae but marks them as disabled, when Valet runs `brew install [email protected]` it fails because Homebrew just aborts due to its flags in the outdated formula.
(They mark it as "disabled" and/or "keg_only :versioned_formula", but don't actually delete the formula from their repository.)
To override that we must use `brew install shivammathur/php/[email protected]` internally.

Therefore, we need to maintain a list of which PHP Versions we wish to specifically prefix with the `shivammathur/php` tap in order to bypass Homebrew's flags.

**ANNUAL MAINTENANCE**
1. This PR adds the array of `LIMITED_PHP_VERSIONS` which we will have to update annually when new PHP versions are retired as others are released.
2. We should also annually update the `LATEST_PHP_VERSION` string.
@drbyte drbyte force-pushed the install-via-alt-tap branch from 92fe7a7 to 615d61d Compare May 6, 2023 02:17
@mattstauffer
Copy link
Collaborator

Fantastic! Thank you!

@mattstauffer mattstauffer merged commit 228b6eb into laravel:master May 12, 2023
@drbyte drbyte deleted the install-via-alt-tap branch May 16, 2023 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem installing PHP 7.4
2 participants