3

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.

JSON Settings

Basic PHP File

Ryan C
  • 43
  • 1
  • 1
  • 6
  • For me the settings is called `"php.executablePath"` – brombeer Apr 05 '21 at 10:35
  • That doesn't seem to be a builtin command. What extension(s) are you using? – Álvaro González Apr 05 '21 at 10:36
  • Does this answer your question? [PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting](https://stackoverflow.com/questions/40287927/php-executable-not-found-install-php-7-and-add-it-to-your-path-or-set-the-php-e) – Gilles Heinesch Apr 05 '21 at 11:26
  • I'm using: PHP Intelephense and PHP Server extensions – Ryan C Apr 05 '21 at 12:30
  • Having the same problem. All my settings are correct and in line with the suggestions on this page, but still the problem persists. Anyone have an answer? –  Feb 18 '22 at 00:28

12 Answers12

5

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://path.to.your.php.folder//php.exe"

Found this solution from php not found visual studio.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • 1
    OP is using PHP Intelephense. As per the [extension instructions](https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client#quick-start), you need to disable builtin PHP support, so you shouldn't even have the `php.validate.executablePath` directive. – Álvaro González Mar 06 '23 at 08:08
2

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.

2

Go 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:

My settings screenshot here

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
1

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 $PATH environment variable.
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
1

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

Jaregui
  • 11
  • 1
0

In 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"
}
Omar Tarek
  • 28
  • 6
  • Thanks, but now the "php.executablePath" line is greyed out and an Unknown Configuration Setting message shows when I hover above the line – Ryan C Apr 05 '21 at 12:29
  • @RyanC sometimes this line: {"php.validate.executablePath": "C:\\xampp\\php\\php.exe"} is enough. So you can leave or remove the greyed out line as long as everything works – Omar Tarek Apr 05 '21 at 15:54
  • You can also check the official docs for that [here](https://code.visualstudio.com/docs/languages/php) – Omar Tarek Apr 05 '21 at 15:56
0

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",
}
0

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

  • 3
    Please add some information for future reference: Which variable did you have to add? What's its value / how to determine it? – ahuemmer Jun 18 '22 at 07:40
0

I 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 for Environment 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.

0

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!

anurupr
  • 2,294
  • 2
  • 20
  • 28
0

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"
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Paula Hill
  • 11
  • 1
0

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.