I am trying to run PHP code on Microsoft VS Code. When I click launch the only thing that happens is an error in the debug console saying:
spawn php ENOENT
To fix this, I have put the dll file for XDebug into the ext folder. I copied php.ini-development into a new file called php.ini and in that file I added this to the end of the file.
zend_extension="[file path]"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
This changed nothing.
Then, I added an inbound rule for my firewall to allow inbound connections on port 9000. Still, nothing changed. How can I fix this?
What fixed it for me, was adding this line to user settings:
"phpserver.phpPath": "c:\\Ampps\\php-7.1\\php.exe"
Your path may vary. (-> error occurs, because your php is not found)
phpserver: This is because I use the PHP Server extension. If you use a different extension, you need a different parameter.
I am using the PHP_DEBUG extension and with a portable laragon environment. I had to make this change to my workspace settings / user settings
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"runtimeExecutable":"D:\\Share\\Dev\\Laragon\\bin\\php\\php-7.3.10-Win32-VC15-x64\\php.exe",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
Basically I had to add the runtimeExecutable line as defined by the PHP_debug extension.
I used this guide to get working with vscode + xdebug + laragon
However I still have an issue, when running individual scripts, that the environment and extensions aren't properly loaded for the CLI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With