How to use Xdebug + Sublime Text 3 to debug PHP code

伊谢尔伦
Release: 2023-03-02 18:08:02
Original
4041 people have browsed it

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
Copy after login

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 ...
Copy after login

Then use package control to install Xdebug Client:

Ctrl+Shift+P->PCI->Xdebug Client
Copy after login

Next, configure the project:

sublime->project->edit poject
Copy after login

Configuration file Similar to the following:

{ "folders": [ { "follow_symlinks": true, "path": "." } ], "settings": { "xdebug": { "url": "http://my.local.website/", } } }
Copy after login

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
Copy after login

This way the project will stop when it reaches this line

Then start debugging, select

tools->xdebug->start debugging(launch browser)
Copy after login
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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!