How to use Visual Studio Code Debugging PHP CLI applications and Web applications

What the public in accordance with the number of articles Jerry? PHP also need to be developed in SAP China Research Institute in? XDebug carried out after local configuration, if you want to use Visual Studio Code rather than the Eclipse to debug PHP applications, the steps are relatively simple.

Start WAMP server, make sure xdebug.remote_autostart, xdebug.remote_enable are on:

Then install the extension of Visual Studio Code: PHP Debug

After installation, File-> Preferences-> Settings:

Add an entry: php.validate.executablePath, point to your local php.exe

Creating a PHP debug configuration, there are two ways to choose:
Launch Current Open Script and Listen for Xdebug:


{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000,
            "runtimeExecutable":"C:\\MyApp\\wamp20190709\\bin\\php\\php7.0.10\\php.exe"
        }
    ]
}

The former debug PHP CLI applications more convenient to open a php file directly to F5, the breakpoint is triggered.


If you choose to Listen for XDebug, the same first F5 to start debugging process,

Then browser to access the PHP file to be debugged, Visual Studio Code breakpoint is triggered, can single-step debugging:

For more Jerry's original article, please pay attention to the public number "Wang Zixi":

Guess you like

Origin www.cnblogs.com/sap-jerry/p/11241298.html
Recommended