What is Q:xdebug?
A:xdebug is an open source PHP debugger that is loaded and used as a PHP module.
Last week found xdebug out of the RC (Release Candidate) 2 version, took down to install a bit, by the way wrote an installation manual, hope for everyone useful.
Installation of Linux Xdebug modules and related tools:
Test environment: ubuntu12.04+php 5.3.10
The code is as follows |
Copy Code |
# get Xdebug Latest source Pack git clone git://github.com/derickr/xdebug.git CD xdebug/ # If Phpize extensions are not installed, try: Apt-get install Phpize Phpize ./configure--enable-xdebug Make && make install |
The path I generated here is:/usr/lib/php5/20090626+lfs/xdebug.so
Then change the php.ini file
Choose to add these configuration options yourself
The code is as follows |
Copy Code |
[Xdebug] ; Extended file path Zend_extension =/usr/lib/php5/20090626+lfs/xdebug.so
; Turn on automatic tracking Xdebug.auto_trace = On ; Turn on exception tracking Xdebug.show_exception_trace = On ; Turn on remote debugging to start automatically Xdebug.remote_autostart = On ; Turn on remote debugging Xdebug.remote_enable = On ; Collect variables Xdebug.collect_vars = On ; Collect return values Xdebug.collect_return = On ; Collect parameters Xdebug.collect_params = On ; Trace format Xdebug.trace_format = 0 ; output folder Xdebug.trace_output_dir=/tmp/xdebug ; Output file name format Xdebug.trace_output_name = trace.%c.%p ; Open Analyzer Xdebug.profiler_enable = On ; Output path Xdebug.profiler_output_dir =/tmp/xdebug ; Output file name format Xdebug.profiler_output_name = cachegrind.out.%p ; Record Memory usage Xdebug.show_mem_delta = On |
Use php-i|grep xdebug query to configure values after configuration is complete
Windows System xdebug module installation
1, to www.xdebug.org download the corresponding version of PHP module files, save the downloaded file to the PHP ext directory, you can modify the name of the file, such as Save into: Xdebug-2.0.0rc1.dll
2, modify php.ini, add the following information
The code is as follows |
Copy Code |
[Xdebug] Zend_extension_ts= "C:/php5/ext/xdebug-2.0.0rc1.dll" Xdebug.auto_trace=on Xdebug.collect_params=on Xdebug.collect_return=on Xdebug.trace_output_dir= "C:/temp/xdebug" Xdebug.profiler_enable=on Xdebug.profiler_output_dir= "C:/temp/xdebug" |
Parameter explanation:
Zend_extension_ts= "C:/php5/ext/xdebug-2.0.0rc1.dll"
; load the Xdebug module. Here can not be loaded in a extension=xdebug-2.0.0rc1.dll way, must be loaded in a ZEND way, otherwise installed on the phpinfo print out of the Xdebug section will have must LOADED as ZEND Warning message for extension (unknown reason).
Xdebug.auto_trace=on;
To automatically open the "Monitoring function call process" of the work mode. This feature can output the monitoring information of function calls as files in the directory you specify. The default value for this configuration entry is off.
Xdebug.collect_params=on;
To open the feature that collects function parameters. The parameter values of the function call are included in the monitoring information of the Function procedure call. The default value for this configuration entry is off.
Xdebug.collect_return=on
To open the collection function return value function. The return value of the function is included in the monitoring information of the Function procedure call. The default value for this configuration entry is off.
Xdebug.trace_output_dir= "C:/temp/xdebug"
The path of the output file that sets the monitoring information for the function call.
Xdebug.profiler_enable=on
, open the Performance Monitor.
Xdebug.profiler_output_dir= "C:/temp/xdebug";
Setting the path of the output file of the performance monitoring information.
There are some more specific parameter settings, see: http://www.xdebug.org/docs-settings.php
3, restart Apache
In this way, when you run PHP locally, you will generate some debugging information files in the directory you set up:
Function call procedure monitoring information file filename format: trace.xxxxxx.xt. This file can be viewed directly, which contains information such as the time the function was run, the parameter value of the function call, the return value, the file and location in which it was located. The content format is still relatively intuitive.
The file name format of the effectiveness monitoring document: Cachegrind.out.xxxxxxxx.
This file can also be viewed directly, but the information format is not easily understood by humans,
So we need the next software.
Second, install Wincachegrind
Due to the effectiveness monitoring document: The content of the Cachegrind.out.xxxxxxxx file is not easily understood by humans, so we need a tool to read it. Windows has one such software: Wincachegrind.
1, to http://sourceforge.net/projects/wincachegrind/download installation Wincachegrind
2, after installation and operation, click Tools->options, set your working folder (php.ini Xdebug.profiler_output_dir value)
This allows for a more intuitive view of the performance monitoring file information.
Another: Do not know which parameter is not set correctly, I machine all PHP function call process monitoring information has been written to a trace.xxxxxx.xt, which talent if you know it to the point of the road bar