How to use Xdebug + SublimeText3 to Debug PHP code

Source: Internet
Author: User
Xdebug is a good helper for php debugging, and sublime is a good helper for php writing. Here we only talk about how to configure it. By default, readers will use sublimetext and Xdebug as a good helper for php debugging and sublime as a good helper for php programming. Here we only describe how to configure it. By default, the reader will use sublime text and Xdebug

Install Xdebug

Install and configure the PHP debugging tool Xdebug in Ubuntu 12.04

Installation in Windows: Installation and Use of PHP debugging tool Xdebug -- a brief introduction to Xdebug

In the PHP configuration file phpl. ini, xdebug needs to enable remote_enable:

xdebug.remote_enable = on

Otherwise, the Xdebug Client will not work properly.

Configure Sublime Text

To debug a project, you must first save the project as a project under sublime:

sublime->project->save project as ...

Then install Xdebug Client using package control:

Ctrl+Shift+P->PCI->Xdebug Client

Next, configure the project:

sublime->project->edit poject

The configuration file is similar to the following:

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

Here, the url is the project url. remember to point this url to 127.0.0.1 in hosts, and point it to the project root directory in apache's virtualhost.

In this case, OK. prepare to enable debugging.

Enable debugging

Enabling debugging is also relatively simple. right-click the place where you want to add a breakpoint

xdebug->Add/Remove breakpoint

In this way, the project will stop when it is running to the bank.

Start Debugging and select

tools->xdebug->start debugging(launch browser)

Sublime will automatically open the browser, enter the link of the website written during configuration, and debug

You can right-click the functions used in debugging in the debugging file to view them.

Possible problems

Failed to track breakpoints

This may be because the xdebug port is occupied. press Ctrl + 'or the menu bar View-> show Console to View the error message. it may be because the xdebug port is occupied.

Disable debugging in sublime xdebug, or restart sublime to solve this problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.