Reputation: 401
I have two xampp versions, one with PHP 5 and another with PHP 7, when I am on PHP 7, I get an error because of an old PHP version
when I check version like in the first image I get 7, but when I run php -v
I get 5
When I run compsoer install
I get the error for old version
I can not understand what's going on!
Upvotes: 0
Views: 151
Reputation: 964
This is because calling PHP from the command line is different then 'calling' it using XAMPP. XAMPP knows where to find the first version, whereas the commandline searches the PATH environment variable for a program with the correct name.
My guess is that you installed php 5 before you installed php 7, so PHP 5 will be earlier in the PATH variable, making it the first to apppear to the command line.
To solve it go to the environment variables and remove the entry for php 5.
If you'd want to keep php 5 in the path, you could add a bat file to the path which calls php 7 specifically. The contents of the file should at least be c:/path/to/php/7 %*
Upvotes: 0
Reputation: 119
You might want to consider changing the "php" alias you use to invoke PHP
commands in the command line, like so:
alias php='/usr/local/
PHP_VERSION_HERE
/bin/php'
Upvotes: 1