Roots Discourse

PHP version issue with composer

So I just pulled a repo to work on locally for a bedrock/sage project and did composer install. Everything was installed fine etc with no warnings or errors.

When I run yarn start I see this error…

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.3.33. in /Users/mike/sites/mt/web/app/themes/maintenance-sage/vendor/composer/platform_check.php on line 24

I have run php -v and get this…

PHP 7.4.26 (cli) (built: Nov 24 2021 14:01:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.26, Copyright (c), by Zend Technologies

Not sure where to go from here. Google hasn’t offered up anything useful.

As far as I know, just because php -v indicates you have a specific version installed doesn’t mean that’s the version that’s used by your web server (local or remote).

So: could you have multiple versions of PHP installed on your machine?

I develop on Ubuntu, and I know that there are multiple versions of PHP installed. I am using Apache to access my site locally and had to specifically configure Apache to use PHP 7.4.

I develop locally using Laravel Valet and that was set to php@7.4 and the only PHP version I have installed was through Homebrew and that was also PHP@7.4 and has been that way since I bought my mac mini 3 months ago.

In the end, the age-old trick of turning it off and on again worked. I restarted all brew services and rebooted my machine and it solved the issue. Strange that it just decided to do that this one time.

ah well :slight_smile:

Further to this issue…

It happened again!! :frowning:

But this time restarting my computer it didn’t fix the issue.

I restarted Valet a few times too which did nothing.

Then I decided to re-select which PHP version Valet was using:

valet use php@7.4 --force

It then work straight away.

Hope this helps anyone with the same issue :slight_smile:

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.