I have a problem with PHP
versions used by composer
. There are hundreds of topics but I still can't find an answer.
I'm using PhpStorm and after I changed CLI Interpreter
to 8.1
Composer still thinks that I'm using the 7.4.5
version.
Command which php
returns /cygdrive/c/Program Files/php/v7.4.5/php
this is where my old version is located.
Also, I disabled Synchronize IDE Settings with composer.json
this is what other people suggested in other topics but no success.
I tried this with other projects even without composer.json
and for some reason, an old version of PHP
is picked.
It looks like the composer
is picking PHP
settings from somewhere and I have no idea how to find them.
CodePudding user response:
If you are using 'composer' executable
option in PhpStorm, then it uses PHP from your PATH
environment (whatever your OS returns for php
executable) and does not depend on what PHP Language Level or what PHP Interpreter you have selected. E.g. 'composer' executable
on Windows is a batch file (composer.bat
) that calls your system-wide PHP internally.
For this option to work you would need to make which php
(where php
on Windows) to point to your PHP 8.1 path. Then restart PhpStorm (or even the whole PC just in case) and it should work with that PHP version.
Here is the ticket that asks about this:
CodePudding user response:
If you know the path to the binary of your desired PHP version (suppose it is /usr/bin/php8.1
), you can use it like this:
/usr/bin/php8.1 `which composer` [...]
instead of
composer [...]
If you have trouble updating/installing requirements having to do with your PHP version, you might consider adding the --ignore-platform-reqs
option.