I'm trying to learn PHP and am encountering some issues early on. When I setup my basic file, then select PHP serve project, I receive a message at the bottom right of the screen saying PHP not found. I've setup my settings for the default xampp php file folder location with the command: "php.validate.executablePath": "c:\xampp\php\php.exe",
Pics are attached. Any help would be really appreciated.
512 Answers
Go to File->Preferences->settings->User settings tab->extensions->from the drop down select php->on the right pane under PHP › Validate: Executable Path select edit in settings.json.
Then set the path as your case may be for a XAMPP user who installed XAMPP on c drive you will have:
"php.validate.executablePath": "c:\\xampp\\php\\php.exe"If PHP is installed in your system independently or by other means simply set the path of your php.exe file like below:
"php.validate.executablePath": "C://"Found this solution from php not found visual studio.
1Go to the PHP Server extension setting. There you have to add the path for:
PHP Config Path: C:\xampp\php\php.ini
PHP Path: C:\xampp\php\php.exe
[Make sure to add your installed folder, if you have installed xampp in another drive, you need to give that specific location.]
My settings:
The PHP Server: Serve project command is not builtin. As the prefix suggests, it's provided by the PHP Server third-party extension. The setting you changed doesn't have anything to do with this feature.
You can find documentation on the extension settings on its Marketplace page, which can also be accessed right from the extension pane within Visual Studio Code.
- Setting:
phpserver.phpPath - Default:
null - Notes: Path to PHP executable. If empty, the extension will try to get the path from the
$PATHenvironment variable.
I am maybe late but the above solutions didn't work for me. My solution was I went to File > Settings > enter php into the search field > enable Suggest and Validate and after just scroll down, let's find the the config path and the php path fields and enter your path.
- PHP Config Path
C:\laragon\bin\php\php-7.4.19-Win32-vc15-x64 - PHP Path
C:\laragon\bin\php\php-7.4.19-Win32-vc15-x64\php.exe
and that's worked for me. I hope I can help you.
0If editing the settings.json file didn't work for you, consider adding the php path into the "advanced system settings" of your windows device (hit Windows + R, then type sysdm.cpl) Once there, go to Environment Variables and click on path, then edit. Within the path section, click on new and paste the path to your php folder (not to the .exe file), then hit okay.
1In VSCode go to File -> Preferences -> Settings
Then add this code
{
"php.validate.executablePath": "C:\\xampp\\php\\php.exe",
"php.executablePath": "C:\\xampp\\php\\php.exe"
} 3 I also run into the same problem just now. This answer is for newer people who will came for the solution:
Put these two lines in your json settings
{
"php.validate.executablePath": "C:\\xampp\\php\\php.exe",
"php.debug.executablePath": "C:\\xampp\\php\\php.exe",
} Well, above didn't work for me. I had to add environment variable for php path. My system - Win10 64bit, VScode v. 1.64.2
1I had to add environment variables to my windows 11 as well.
Environment variable is simply the path. For instance,
D:\Backend\Xampp\php
Then type environment variables and select 'Edit the system environment variables. Look forEnvironment Variables > click path (Top) > Edit (from the top) > New and paste the path of wherever you installed your Xampp. Make sure to point to the php folder.
I am working on a school computer and found a way to fix all of these problems for myself!
So when installing the "PHP Server" extension, you want to have PHP installed. After that is done you find the path to the PHP binary and add it to the executable path in the extension settings. I personally installed PHP to my USB drive since these computers always reset.
Hope this helps!
Probably late but leaving this here for the people who may encounter this in future,
If Nothing mentioned above is working for you then go to the PHP Server extension setting on marketplace and change the default null value of Phpserver: PHP Path to c:\xampp\php\php.exe or whatever path your php.exe is in. Hope that helps.
I'm on a windows machine, so I added the following key-value pair to the json file:
"php.validate.executablePath": "C://wamp64/bin/mysql/mysql5.7.36/bin/mysql.exe" 0