VS code uses an exceptional lightweight code editor with plug-in tools that are numerous and growing. Using vs code to debug PHP code is more convenient and concise, let's look at it together.
1. Installing the XDebug Extension
The most common use of debugging PHP code is the XDebug extension, first we need to install the extension tool first.
The following I recommend a very convenient way to install the XDebug extension, first create a new phpinfo file to get to phpinfo content, all copied to the XDebug detection URL in the input box, see:
After a moment, the site will analyze the most appropriate version of the Xdebug for your current PHP environment, and give the download link, see:
When the download is complete, copy the file to the extension directory in PHP, which is under the Ext folder in the installation directory.
2. Set PHP to use XDebug
Add a row to the php.ini configuration file zend_extension=path/to/xdebug , which path/to/xdebug is the Xdebug installation directory plus the file name.
Now, looking again at the contents of the Phpinfo file output, you should be able to see the xdebug enabled.
3. Enable remote debugging
Add the Xdebug configuration entry in the php.ini configuration file:
[XDebug]xdebug.remote_enable = 1xdebug.remote_autostart = 1
4. Add a VS Code extension
Search for PHP Debug extensions and install in VS code.
The installation is complete, the following can be tested, in the debug interface of the VS code to open debugging, choose to add Xdebug configuration
Below, you can add a short point, debugging at will.
69692096
debugging PHP with a vs code breakpoint