After running sudo apt-get update && sudo apt-get dist-upgrade
on my Laravel app, I’m getting this error on the next deployment:
- This package requires php ^7.1.3 but your PHP version (8.1.6) does not satisfy that requirement.
In my composer.json, ^7.1.3 is the specified version. This is my first time running the apt-get update and I don’t know why the php version got updated as well.
On each deployment I run
composer install --no-interaction --prefer-dist --optimize-autoloader
How can I downgrade the version to 7.1.3? This happens on an existing app in production and I have to be very careful about it.
2
Answers
The php version installed on your environment should be compatible with your project.
If your project is based on composer package manager (as I see), it can help you to control which php version you need on the server.
In your case I would recommend to restore from the snapshot or just install php 7.1.3 version back.
If you want to use php 7.4/8/8.1 in your project, before you should upgrade your code and project dependencies and ensure, that everything working fine with the desired version of php.
Old topic, but for things like this, I recommend adding the flag to ignore requirements like this. So try:
There may be incompatibilities with your project using 8.1 instead of 7.1.3, but I doubt it. But still, only do this if you feel confident the PHP version won’t be an issue. It’s usually better than downgrading, however.