close

How to change PHP version used by composer

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error How to change PHP version used by composer 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 to change PHP version used by composer Error Occurs?

Today I get the following error How to change PHP version used by composer in php.

How To Solve change PHP version used by composer Error ?

  1. How To Solve change PHP version used by composer Error ?

    To Solve change PHP version used by composer Error Another possibility to make composer think you're using the correct version of PHP is to add to the config section of a composer.json file a platform option.

  2. How to change PHP version used by composer

    To Solve change PHP version used by composer Error Another possibility to make composer think you're using the correct version of PHP is to add to the config section of a composer.json file a platform option.

Solution 1

You can change php version of composer without uninstalling it, follow these steps :

  1. Search for system environment variables in cortana.
  2. Click on the button “Environment variables”.
  3. Under “System variables” select path and click on edit, you will see one entry like this “C:\wamp\bin\php\php5.6.13”.
  4. Just change this to the folder name of the php located at your wamp/bin/php7.1.9, here php7.1.9 is folder name.
  5. Replace php5.6.13 with bin7.1.9, it will look like these “C:\wamp\bin\php\php7.1.9”, just click ok on all the boxes.
  6. You are done.
  7. To verify, first close all the cmd windows, than open cmd and type php -v, press enter and you should see php7.1.9.
  8. If you don’t see change in php version than just restart your pc and run php -v again in cmd , it will work.

Solution 2

Another possibility to make composer think you’re using the correct version of PHP is to add to the config section of a composer.json file a platform option, like this:

"config": {
    "platform": {
        "php": "<ver>"
    }
},

Where <ver> is the PHP version of your choice.

Snippet from the docs:

Lets you fake platform packages (PHP and extensions) so that you can emulate a production env or define your target platform in the config. Example: {“php”: “7.0.3”, “ext-something”: “4.0.3”}.

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