Composer Version Mismatch

I’ve written about managing composer version with php in the past. But today i ran into an oddity and I wanted to share, just in case you ever run into the same issue!

Here’s the scenario:

  • I recently updated a codebase to PHP 8.0

  • I deployed that code to my hosting account

  • I was forced to update to Mac OS Big Sur

And randomly today on the project I started seeing this error:

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.4.21. in /mnt/www/html/eemmadisondev/vendor/composer/platform_check.php on line 24         

This was maddening for me, because I knew I was running PHP 8 and obviously I had updated everything to PHP 8. So what the heck was going on?

php -v
PHP 8.0.10 (cli) (built: Aug 26 2021 15:36:17) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.10, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.10, Copyright (c), by Zend Technologies

Everything here looks good. I also used homebrew to unlink / relink PHP just to be safe to no avail.

I started getting very suspicious when I started mucking about with composer though… I actually delted the contents of the platform_check.php file and I was still getting the error!

That’s when I noticed the path of the platform_check.php file. The /mnt path is definitely not one that lives on my local machine. This was an immediate face palm moment for me: the error in question was actually coming from my Acquia server because while I had merged the PR with the PHP 8.0 update… I hadn’t actually updated the server’s PHP config to run PHP 8.0.

So in this case, the fix was just to update the PHP config on my webserver to be PHP and re-deploy everything and what do you know, everything worked as expected. This is a prime example of doing “everything the right way” and “following a proper dev-ops process” but still overlooking a small (but absolutely critical) component of the process. And in this case, it was the dev environment so it wasn’t a huge deal! But it’s an important reminder of how important it is to carefully test all of your deployments (even if they look like they’ve succeeded) to ensure that the environment still works as expected in a post-deploy state.

In this case, no harm no foul. But this totally could have been a production environment, and I would have brought down the entire environment (because the composer version mismatch caused the entire site to stop being responsive, let alone bootstrap and run).

So do all the things! Use composer to manage PHP. Use your CI / CD process to test it out. Just make sure you finish the configuration on the other side.

Related Content