Use Xdebug and Sublime 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 only how to configure, the default reader will use sublime and xdebug to install xdebug in mac is very convenient: brewinstallphp55-xdebug and then configure, add xdebug. remote_enab in usrlocaletcphp5.5conf. dext-xdebug.ini

Xdebug is a good helper for php debugging, and sublime is a good helper for php writing. Here only how to configure, the default reader will use sublime and xdebug install xdebug in mac is very convenient: brew install php55-xdebug and then configure, in/usr/local/etc/php/5.5/conf. d/ext-xdebug.ini add xdebug. remote_enab

Xdebug is a good helper for php debugging, and sublime is a good helper for php writing. This document only describes how to configure it. By default, the reader will use sublime and xdebug.

Install xdebug

It is very convenient on mac:

brew install php55-xdebug

Then configure/usr/local/etc/php/5.5/conf.d/ext-xdebug.iniAdd

xdebug.remote_enable=1xdebug.remote_handler=dbgpxdebug.remote_host=127.0.0.1xdebug.remote_port=9000xdebug.remote_log="/var/log/xdebug/xdebug.log"

Restart apache

sudo apachectl restart
Configure sublime

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

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

Use package control to installxdebug client

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 cannot be traced to 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.

Reference
  1. Debugging with Xdebug and Sublime Text 3

Original article address: Use Xdebug and Sublime to debug the PHP code. Thank you for sharing it with the original author.

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.