How to change PHP version used by composer

composer change php version windows
composer change php version mac
composer change php version ubuntu
change php version windows 10
composer specifying php version
run composer with different php version
composer using wrong php version
check composer-php version

I want to use another php version on my machine than the one already installed using WAMP (2 PHP version installed).

  • The composer installed uses PHP 5.6
  • A new project requires PHP7.0.

Whenever I choose PHP 7 from the control panel of WAMP and then run php -v it still printing PHP5.6 (CLI)... instead of PHP7.

How can I use PHP7 without reinstalling the composer again?

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.

Change php version used by composer on windows · Issue #6277 , We can tell Composer what version of PHP we are supporting with our we try and install or update a package with Composer the faked platform than the version of PHP being used on the command-line we are running  I don't understand why my composer is using a 5.4.45 php version when i don't see such version on my computer, i use wamp with php 5.6.25 , in my environmemt variable i have the this version on top of the list of path value. Is there a want to change the version composer is using please ?

I'm assuming Windows if you're using WAMP. Composer likely is just using the PHP set in your path: How to access PHP with the Command Line on Windows?

You should be able to change the path to PHP using the same instructions.

Otherwise, composer is just a PHAR file, you can download the PHAR and execute it using any PHP:

C:\full\path\to\php.exe C:\full\path\to\composer.phar install

Enforcing a PHP Version for Installed Composer Packages, To prevent the installation of packages which won't be compatible on the live server, you can define the PHP version used for composer to  Change PHP version used by Composer on Windows (2 answers) Closed 6 months ago . I have multiple versions of php installed on my wamp . now I am running PHP 7.0.15 as you can see in screenshot, but the laravel I am using is still taking 5.5.12 and I am unable t use laravelcollective .

If anyone is still having trouble, remember you can run composer with any php version that you have installed e.g. $ php7.3 -f /usr/local/bin/composer update

Use which composer command to help locate the composer executable.

Force composer to use specific PHP version, I have two php versions installed on my system php 5.3 and php 5.6 When /​29907807/how-to-install-laravel-on-a-server-running-different-php-versions to ensure the configured version of php (for webserver) is used on command line. In this example we are faking the version of PHP to 5.6.1. This means that whenever we try and install or update a package with Composer the faked platform version of PHP will be taken into account rather than the version of PHP being used on the command-line we are running Composer from. This is really useful if our production environment uses

Run composer commands with different php versions, Recently we upgrade to the next version of laravel framework, this new versions required php 7.+, we already switch to this php version through cpanel, but the  Composer uses the default php version in your terminal, you can easily manage that using phpbrew and switch between the different versions of php in your terminal. Alternatively, you can edit ~/.bashrc and add aliases to the php versions you want to use

Command-line interface / Commands, now how can i make or configure composer to take php 5.4 of wamp as current version instead of xampp 5.3 ?? or do it have install the composer again ?? vineet. 2. version history. If composer modified its own cache files when external changes occurred, it would be difficult to know which packages versions were compatible with each other, and when. So, composer is not checking the php version when an update or install is occurring, it references its cache.

Is there way to use two PHP versions in XAMPP?, I have already use WAMP 25 with PHP 5512 and with ComposerThe php is onCwampbinphpphp5512For new project I need to use nginx and install Do you want to set php version by composer and this version will be used by your app? The way I offered will only change php version for composer script and nothing else. If you want to manage multiple projects with multiple php versions you better try docker or vagrant . – marv255 Oct 20 '17 at 7:58

Comments
  • this works BUT the wamp server says it has an error and that it has detected a change in environment variables.
  • If wamp server shows error about change detection in environment variables I suggest you to restart server. If it does not solve than shutoff server and than start it again. If that also does not work than I suggest you to restart your pc. Hope it helps :)
  • What is the use of this line C:\full\path\to\php.exe C:\full\path\to\composer.phar install . I already have the composer.phar file since I'm already using composer in my current project
  • Composer phar example is golden! Finnaly got it working, no need of endless enviroment variables switching. Tnx much!
  • For Linux/MacOS users, would be something like: /Applications/MAMP/bin/php/php7.2.14/bin/php /usr/local/bin/composer install