Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft VS Code: When I try to launch my program error "spawn php ENOENT" shows up

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?

like image 664
Sam Hiner Avatar asked Mar 12 '18 17:03

Sam Hiner


2 Answers

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.

like image 128
Ralf Avatar answered Nov 13 '22 09:11

Ralf


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

like image 9
Vijay Avatar answered Nov 13 '22 08:11

Vijay