In linux, vim implements phpDBGp + xdebug + xdebughelper remote debugging environment setup

Source: Internet
Author: User
There are three, vim DBGp plug-ins, php xdebug extensions, and Chrome xdebughelper extensions.

First, install required components.
There are three, vim DBGp plug-ins, php xdebug extensions, and Chrome xdebug helper extensions.

I. Install the dbgp client plug-in vim
Download DBGp client

$ cd ~/.vim/$ wget http://www.vim.org/scripts/download_script.php?src_id=7285 -O debugger.zip$ unzip debugger.zip

Ii. Install xdebug extension in PHP
I will not discuss the specific installation method. There are many online examples. Official installation instructions.
I posted my configuration information:
Sudo vim/home/s/apps/php-5.2.6/etc/include/xdebug. ini

[Xdebug] zend_extension = "/home/s/apps/php-5.2.6/lib/php/extensions/no-debug-non-zts-20060613/xdebug. so "xdebug. profiler_enable = 0; Enable profilexdebug. profiler_enable_trigger = 1; Use the trigger to enable profilexdebug. profiler_output_dir = "/home/s/logs/xdebugLog" xdebug. auto_trace = 0; Enable tracexdebug. trace_enable_trigger = 1; Use the trigger to enable tracexdebug. trace_output_dir = "/home/s/logs/xdebugLog" xdebug. cli_color = 1xdebug. collect_params = 2 xdebu G. collect_return = on; remote debug; enable remote debugging xdebug. remote_enable = 1xdebug. remote_autostart = Offxdebug. remote_port = 9000; remote port, not the port of your web service. If there is no conflict, do not modify it.

Note that profile and trace are not automatically enabled when there is a comment, because the corresponding information will be saved in each request and the disk will be destroyed. Open the trigger so that the performance information is recorded only when specific information is contained in the request. Trigger Implementation Mechanism: If the GET/POST/COOKIE information contains specific variables during a request, the corresponding debug, profile, or trace will be enabled, therefore, you can enable the corresponding functions by adding corresponding variables when accessing the page on the web. If you splice this one by yourself every time, it will be quite troublesome, so we will introduce the chrome extension of xdebug helper later. If you want to enable any function, click the extension. That is to say, this extension is not required for debugging, but it will make you feel very convenient to use.

Iii. chrome extension xdebug helper
Address: https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc
If you cannot find xdebug helper in chrome: // apps, remember to change your language to English.

Xdebug-helper-introduction20140226142342


Note the xdebug helper configuration,
For the IDE Key, select Other with a value of 1 and save it.
The second is the domain white list. If you do not want debug icons on every page, enter the domain name during development, for example, localhost. In fact, the icon is very small and does not get in the way. You do not need to set it.

Start to use:
If debugging is not required, you only need to record the profile and trace information and check the performance problem. It is very easy to directly access the corresponding url in chrome, A small xdebg helper icon is displayed on the right of the url. Click profile or trace and refresh it. Then, you can see the corresponding file in the pre-configured directory.
Cachegrind * is a profile file, and trace * is a trace file.
Using WinCacheGrind in windows allows you to conveniently view profile information.

Xdebug_helper_debug_profile_trace

Xdebug_output_file_trace_profile

WinCacheGrind_output

Finally, yesHow to enable remote debugging.
Use vim to edit the program file and use Bp where the program file needs to be interrupted.CommandPlace a breakpoint. Then press F5 to execute the listener.

At this time, vim will prompt waiting for a new connection on port 9000 for 5 seconds... In this case, you need to initiate an interrupt request to the server within 5s. In the url address at the front, we select xdebug helper's debug to refresh the page, vim will be interrupted. There are related prompts on the right side, so we can debug it step by step using GDB. If xdebug helper is not installed, You can manually splice a parameter on the url: & XDEBUG_SESSION_START = 1 to enable remote debugging.

 

Xdebug_remote_debug_how

Related Article

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.