Debugging PHP configuration with VS Code breakpoints

1. Install the XDebug extension

The most commonly used extension for debugging php code is the XDebug extension. First of all, we need to install this extension tool. 
Below I recommend a very convenient way to install the XDebug extension, first create a phpinfo file to get the content of phpinfo and then open the copy

Copy all directly

Copy all of them to   the input box in the  XDebug detection URL
 
, as shown in the figure below: Click, after a while, the website will analyze the most suitable xdebug version for your current php environment, and give the download link, as shown in the figure below: 
 
Download complete After that, copy the file to the extension directory of php, that is, the ext folder in the installation directory.

2. Setting up PHP to use XDebug

Add a line to the php.ini configuration file  zend_extension=path/to/xdebug, which  path/to/xdebug is the installation directory of xdebug plus the file name. 
Now, look at the output of the phpinfo file again, and you should see that xdebug is enabled, as shown below.

3. Enable remote debugging

Add the xdebug configuration item in the php.ini configuration file:

[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

 

4. Add VS Code extension

Search for the PHP Debug  extension in vs code  and install it.

After the installation is complete, you can test it below. Start debugging in the debug interface of vs code, and choose 
 
to add a breakpoint under the configuration of xdebug, and you can debug it at will.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325845966&siteId=291194637