Home > Article > Backend Development > How to use Xdebug + Sublime Text 3 to debug PHP code
Xdebug is a good helper for PHP debugging, and sublime is a good helper for PHP writing. Here I only talk about how to configure. By default readers will use sublime text and A brief introduction
In the PHP configuration file phpl.ini, xdebug needs to turn on remote_enable:
xdebug.remote_enable = on
Otherwise, Xdebug Client will not work properly.
Configuring Sublime Text
To debug a certain project, you must first save the project as a project under sublime:
sublime->project->save project as ...
Then use package control to install Xdebug Client:
Ctrl+Shift+P->PCI->Xdebug Client
Next, configure the project:
sublime->project->edit poject
Configuration file Similar to the following:
{ "folders": [ { "follow_symlinks": true, "path": "." } ], "settings": { "xdebug": { "url": "http://my.local.website/", } } }
where url is the url where the project is located. Remember to point this url to 127.0.0.1 in hosts, and point it to the project root directory in apache's virtualhost
This is OK. Prepare to start debugging.
Enable debugging
Enabling debugging is also relatively simple. Right-click where you want to add a breakpoint
xdebug->Add/Remove breakpoint
This way the project will stop when it reaches this line
Then start debugging, select
tools->xdebug->start debugging(launch browser)in the menu bar
sublime will automatically open the browser, enter the website link written during configuration, and debug.
The functions used in debugging can be viewed by right-clicking in the debugging file.
Possible problems
Unable to track breakpoints
This may be the xdebug port If it is occupied, press Ctrl+` or View->show Console on the menu bar to check the error message. It may be that the xdebug port has been occupied.
Turn off debugging in sublime xdebug or restart sublime to solve this problem.