skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. Old topic, but for things like this, I recommend adding the flag to ignore requirements like this. So try:

    composer install --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-reqs
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search