Local Community

How to link LocalWP PHP and Composer installations to VSCode?

Issue Summary

I’m running LocalWP on my Mac Book Pro, and I didn’t install PHP or Composer locally on my machine since LocalWP handles all of that. Also, I’m using VSCode for coding, and I get this error message whenever I edit a PHP file:

Cannot validate since a PHP installation could not be found. Use the setting 'php.validate.executablePath' to configure the PHP executable.

I installed the Xdebug + VS Code add-on and tried again, but I got the same error. And I got the following error when I tried to run the PHP file in the Debug mode:

PHP executable not found. Install PHP and add it to your PATH or set the php.debug.executablePath setting

Troubleshooting Questions

  • Does this happen for all sites in Local, or just one in particular? I have only one site.

  • Are you able to create a new, plain WordPress site in Local and access it in a Browser? Yes.

System Details

  • Which version of Local is being used? 6.3.0+5756

  • What Operating System (OS) and OS version is being used?

    • macOS Monterey 12.2.1
  • Attach the Local Log. See this Help Doc for instructions on how to do so:

My question

Is there any way to make the VSCode recognize the PHP, Composer, and other installations that are already running with LocalWP? I don’t want to install another instance of each while I already have existing instances running.

And how to fix the Xdebug issue?

Best Regards,
Jaafar

3 Likes

Same issue in Windows, maybe I missign something in VSC. I do not know if this is correct:

{

"workbench.editor.enablePreview": false

php.validate.executablePath:"C:\Program Files (x86)\Local\resources\extraResources\lightning-services\php-7.4.1+16\bin\win64\php.exe"

}

I use PHP Debug extension (by Xdebug) in VSC.
I figure it out that deletting all files launch.json in .vscode from Local public folder and applying again ADD RUN CONFIGURATION TO VS CODE from Xdebug + VS Code seems to work.
I have managed to start debugger an apply a breakpoint successfully by opening in VSC menu File > Open Folder in root Local Public folder .
So far it works.

Thank you @ignasitort !! I tried that and it worked.

I took a backup of the old launch.json file and followed your steps and it worked. But the strange part is that the new launch.json file has exactly the same content as the old one. It could be that running the CONFIGURATION again fixes something somewhere else.

Anyway, it worked!! Thank you!!

I agree with you that it seems strange to me also, which means that I do not fully understand how it works internally. You are welcome.

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