Composer dependencies require PHP version – Code Example


Php throws error composer dependencies require php version > abc when you have lower php version installed in your system.


1. Run php -v to get the php version installed on your system

php -v

If this version is lower than what composer wants, then upgrade php. Otherwise, it might be the possibility that you have installed multiple php versions and command line is running on higher version while GUI on lower.

2. Check PHP_VERSION_ID or use phpversion() function

echo phpversion();

This will print the php version for web or GUI. If it is lower than what composer is demanding, then upgrade it.

3. Disable the older version and use newer version

sudo a2dismod php8.0

sudo a2enmod php8.1

sudo systemctl restart apache2