Sudden PHP configuration error on VS Code

What issue or error are you experiencing?

“Cannot validate since a PHP installation could not be found. Use the setting ‘php.validate.executablePath’ to configure the PHP executable.”


What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc

php-bug


System Details

  • Local Version: > I updated a few minutes ago to the latest Local WP version that is 7.1.2. This PHP configuration error started occuring when Local WP was still 7.1.0 version. I don’t know why all of a sudden this bug appeared and not sure what is the cause

How do I fix it?

  • Operating System (OS) and OS version:

Microsoft Windows 10 Home


Security Reminder
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

Hi @Leta!

There have been a few threads with this error around the forums. It looks like this Windows user was able to get it working:

Hi @Nick-B

it still is not clear how I can fix my PHP issue, I am extremely confused

I never used PHP debug extension, and before I started using LocalWP I used wamp and that worked differently

where to find this launch.json file in .vscode from Local public folder?
Where is this Local public folder? I have several websites on my LocalWP and all my websites there use WordPress so PHP too

The only way I could find this launch.json was by opening a JS file in vs code then from the top menu “run without debugging” I picked “Chrome” and I was shown the screenshot I enclosed to this message

should I delete everything in launch.json and this file looks the same no matter what JS file I decide to “run without debugging”, if it is Chrome or anything else ?

is this the launch.json which lines of code have to be removed fully or what files should be deleted ?

how do I “add run configuration to vs code” from PHP debug extension ?

How do I start debugging and apply a breakpoint by opening in VS Code:
File > Open Folder in root Local Public folder ?

Can you clarify these points for me?
Let me know, thanks
Leta

Hi @Leta

If you click on the Add Ons tab in Local, there is an Extension for Xdebug + VS Code.

Here is a screenshot

Even though you might not be trying to use XDebug, in the process of adding the configuration to VSC, it should point VSC to a server run by XDebug, which in turn points to PHP. Xdebug is acting kind of like a middleman to the PHP.

You could also try to set the php.validate.executablePath to the actual path of the PHP binary we ship - here’s that info:

For Windows:

Bundled PHP (for now, this will change in 7.2):

<LOCAL INSTALL LOCATION>Local\resources\extraResources\lightning-services\php-8.1.9+8\bin\win64

Other PHP versions:

C:\Users\<USERNAME>\AppData\Roaming\Local\lightning-services\php-<VERSION+BUILD>\bin\win64

Hi @Nick-B

Thanks for your explanation

Option 1:

  1. I installed the LocalWP add-on “Xdebug + VS Code” and enabled and re-launched LocalWP after that
    2.I installed “PHP Debug” extension by Xdebug on VS Code
  2. I started one of my websites on LocalWP then > Tools (Tab) > Add run configuration to VS Code
  3. I got the notification that the configuration to VS code was added
    (I believe it is here app/public/launch.json)
{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "Listen for Xdebug 3.0 (Local)",
			"type": "php",
			"request": "launch",
			"port": 9003,
			"xdebugSettings": {
				"max_children": 128,
				"max_data": 1024,
				"max_depth": 3,
				"show_hidden": 1
			}
		},
		{
			"name": "Listen for Xdebug (Local)",
			"type": "php",
			"request": "launch",
			"port": 9000,
			"xdebugSettings": {
				"max_children": 128,
				"max_data": 1024,
				"max_depth": 3,
				"show_hidden": 1
			}
		},
		{
			"name": "Launch currently open script",
			"type": "php",
			"request": "launch",
			"program": "${file}",
			"cwd": "${fileDirname}",
			"port": 9000,
			"xdebugSettings": {
				"max_children": 128,
				"max_data": 1024,
				"max_depth": 3,
				"show_hidden": 1
			}
		}
	]
}
  1. Then I opened a PHP file on VS Code and clicked on Run > Start debugging
    I attached the error message I got
    xdebug-error

Option 2:

I tried to add to my VS code in settings.json
"php.validate.executablePath": "C:\...........\Local\resources\extraResources\lightning-services\php-8.1.9+8\bin\win64"

but this is the error message I got “Invalid escape character in string.”

How to remove these error messages?
I would prefer fixing option 1 as I want to have LocalWP to always be ok with its PHP configuration no matter the version of LocalWP

Let me know, thanks
Leta

Hi @Nick-B

Can you help me fixing this PHP issue?
I still have the same issue as of my last post in this thread

Let me know, thanks
Best regards,
Leta

Hi @Leta

I checked with one of our Devs on this and they mentioned that you may want to start by removing the php.validate.executablePath from settings.json

From there, double-check that you’re doing the steps from that other thread. So remove and launch.json file in the <sitename>/app/public and <sitename>/app/public/.vscode folders and then re-add the file by clicking in the Local under “Site Overview > Tools > Xdebug + VS Code > Add run Configuration to VS Code”

@Nick-B php.validate.executablePath kept recreating itself from settings.json

for anyone else that might have had the same bug, I finally fixed it :smiley: by replacing the backslash \(that is automatically present when you copy the file path) with forward slash /:

"editor.codeActionsOnSave": {

    },
    "php.validate.executablePath": "…./Local/Programs/Local/resources/extraResources/lightning-services/php-8.1.23+0/bin/win64/php.exe"
}
1 Like

Thank you for the follow up @Leta!

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.