I have mac os sierra machine. When I start a php project in vs code, I get the following warning
language server needs php 7, and the version found is 5.6.27.
So I used homebrew to upgrade to version 7 and confirmed it from the terminal. I am also running mamp which show version 7. But in the terminal of vs code the php version is still 5.6.27. So I am bit confused?
I changed the value of php.validate.executablepath
in settings.json
in vs code from usr/bin/php
to usr/local/bin/php
, but still vs code terminal showing the older version (viz. 5.6.27)
This is because VM Code still checking /usr/bin/php directory which is php5
You have to configure the path to the PHP executable in the user settings file. Follow the following steps to change it
Change the value of php.validate.executablePath according to the installed directory of php7.
"php.validate.executablePath": "/Applications/MAMP/bin/php/php7.0.14/bin/php"
Relaunch VM Code
If the problem remains same, then add the path to PHP7 to your environment variables, run where php and php --version to verify. To add path in your macos sierra do the following:
Type i and then paste the following at the top of the file:
export PATH=/user/local/bin:$PATH
Hit ESC, Type :wq, and hit Enter.