How to debug PHP code using Xdebug + Sublime Text 3

Source: Internet
Author: User
Tags config php php debug
Xdebug is a good helper for PHP debugging, Sublime is a good helper for PHP writing. Here only how to configure, default readers will use sublime text and Xdebug

Installing Xdebug

Ubuntu under Installation: Ubuntu 12.04 under install config PHP debug tool xdebug

Windows Installation: PHP debugging tool Xdebug installation and use of--xdebug simple introduction

Xdebug need to turn on remote_enable in PHP config file Phpl.ini:

Xdebug.remote_enable = On

Otherwise the Xdebug client will not work properly.

Configuration Sublime Text

To debug a project, you first need to save the project under sublime as one project:

Sublime->project->save Project as ...

Then install the Xdebug Client with the package control:

Ctrl+shift+p->pci->xdebug Client

Next configuration item:

Sublime->project->edit Poject

The configuration file resembles the following:

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

Where the URL is the URL of the project, remember to point the URL to 127.0.0.1 in the hosts, and in Apache VirtualHost point it to the project root directory

This is OK, ready to start debugging.

Start debugging

Debugging mode is also relatively simple, where you want to add a breakpoint right-click

Xdebug->add/remove Breakpoint

So the project will stop when it runs to the bank.

Then start debugging, and in the menu bar select

Tools->xdebug->start Debugging (Launch browser)

Sublime will automatically open the browser, enter the configuration of the site link to write, to debug

The functions used in debugging can be viewed in the debug file by right-clicking the

Possible problems

Breakpoint cannot be traced

This may be the Xdebug port is occupied, press CTRL + ' or the menu bar View->show console to view the error message, it is possible that the Xdebug port has been occupied for the sake of.

Turning off debugging in sublime Xdebug, or restarting sublime, can 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.