close

[Solved] Laravel Composer sees wrong PHP Version

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Laravel Composer sees wrong PHP Version in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Laravel Composer sees wrong PHP Version Error Occurs?

Today I get the following error Laravel Composer sees wrong PHP Version in php.

How To Solve Laravel Composer sees wrong PHP Version Error ?

  1. How To Solve Laravel Composer sees wrong PHP Version Error ?

    To Solve Laravel Composer sees wrong PHP Version Error Whats happening here is when he runs php -v he is running php-cli which is configured to run in php7, but perhaps his apache has 5.5 enabled. so

  2. To Solve Laravel Composer sees wrong PHP Version Error

    To Solve Laravel Composer sees wrong PHP Version Error Whats happening here is when he runs php -v he is running php-cli which is configured to run in php7, but perhaps his apache has 5.5 enabled. so

Solution 1

I’ve had this problem too. If you don’t want to update all your composer packages, you can solve this issue by manually changing the composer.lock file and writing your actual PHP version in platform > php in the JSON object.

Example

...
"platform": {
    "php": "7.1"
}
...

Although it works, the most recommended way to do this would be deleting your composer.lock file, changing the platform > php version in composer.json and then executing composer install.

Solution 2

this is a config/env issue. Ideally you can have multiple php versions to test with, in apache you can swap versions like this:

Example:
sudo a2dismod php5.6
sudo a2enmod php7.0
sudo service apache2 restart

Whats happening here is when he runs php -v he is running php-cli which is configured to run in php7, but perhaps his apache has 5.5 enabled. so

sudo a2dismod php5.5
sudo a2enmod php7.0
sudo service apache2 restart

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment