Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change php version used by composer on windows #6277

Closed
crashbdx opened this issue Mar 19, 2017 · 12 comments
Closed

Change php version used by composer on windows #6277

crashbdx opened this issue Mar 19, 2017 · 12 comments
Labels

Comments

@crashbdx
Copy link

Hi everyone,

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 ?

@alcohol
Copy link
Member

alcohol commented Mar 20, 2017

I don't understand why my composer is using a 5.4.45 php version

Please explain what this means, where this information comes from, or what you are basing this on. Because it makes zero sense without any actual context.

@Seldaek
Copy link
Member

Seldaek commented Mar 20, 2017

@crashbdx the PATH value should contain the directory of the php.exe, not the full path including php.exe, just in case there is some confusion there.

Composer is not at fault in any case as this is OS/shell-level resolution.

If you're on windows you can type where php to see which php is used, or in bash on linux/OSX type which php.

@Seldaek Seldaek closed this as completed Mar 20, 2017
@denisdulici
Copy link

@crashbdx the only way is to uninstall and install it again 😉

@alcohol @Seldaek it would be nice if there were an option to change the following option without having to uninstall => install:

2017-07-05_1025

@alcohol
Copy link
Member

alcohol commented Jul 5, 2017

@denisdulici such requests should really be posted to composer/windows-setup. Then @johnstevenson can have a look at it and see how feasible it is :-)

@treetechsuman
Copy link

the only way is to uninstall and install it again 😉 work for me

@geeky3
Copy link

geeky3 commented Mar 9, 2018

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

@linslin
Copy link

linslin commented Aug 3, 2018

IMO there is no need to switch the environment variables just for running composer commands with a different PHP Version (which were not set in your env paths.). Just run your composer.phar with a absolut PHP execution file path and you will be fine. Command pattern: $ <pathToPhPExecutionFile> <pathToComposerPhar> install.

This should do it if you have composer installed globally:

  • On windows e.g.: C:\xampp\php\php.exe C:\ProgramData\ComposerSetup\bin\composer.phar install
  • On *ngix run e.g.: /usr/bin/php /usr/local/bin/composer install

@AndrasZiegenham
Copy link

DependencyResolver easily eats up over 1GB and 32bit php is limited to 2GB memory use and oddly enough I get fatal errors near 1.3GB, so I have to use a 64bit php just for composer.

So according to this (and this: composer/windows-setup#72) topic the devs apparently don't care about this sort of problem and want you to change your whole system's environment to a different php... noice...

The only workaround seems to be the one mentioned by @linslin even though one can end up with monsters like this (using GitBash on windows):

/c/php/php-7.2.9-Win32-VC15-x64/php.exe -d memory_limit=-1 "c:\ProgramData\ComposerSetup\bin\composer.phar" update

Really, am I supposed to write this instead of "composer update"? Legit.

@RahulDey12
Copy link

image
check out this i have composer installed and php command working on my pc but there is no php in path variable

@stof
Copy link
Contributor

stof commented Feb 24, 2020

@RahulDey12 check both the user list and the system list. Both provide values for the PATH variable.

@jonathanlaf
Copy link

Same has @RahulDey12 I can't find it, even on user list and system list! Where the heck did Composer created that link 😲 ?

@HamidulloRahmonberdiyev

Hi. My project is has this error. "Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.9". You are running 8.0.22. in C:\OSPanel\domains\task-manager\vendor\composer\platform_check.php on line 24"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests