PHP extension Xdebug Installation use instance _php Tutorial

Source: Internet
Author: User
Tags php debugger
What is Xdebug? It is a can be used to debug PHP code to run a tool, the following small section to introduce Xdebug installation method, the following tutorial is based on Linux and Windows system OH.

What is Q:xdebug?

A:xdebug is an open source PHP debugger that is loaded and used in the form of a PHP module.

Last week found xdebug out of RC (Release Candidate) 2 version, took down to install a bit, by the way wrote a installation manual, hope to be useful to everyone.

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 Package
git clone git://github.com/derickr/xdebug.git
CD xdebug/
# If the phpize extension is not installed, try: Apt-get install Phpize
Phpize
./configure--enable-xdebug
Make && make install

My side of the generated path 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 auto-tracking
Xdebug.auto_trace = On
; Turn on exception tracking
Xdebug.show_exception_trace = On
; Turn on remote debugging auto-start
Xdebug.remote_autostart = On
; Turn on remote debugging
Xdebug.remote_enable = On
; Collecting variables
Xdebug.collect_vars = On
; Collect return values
Xdebug.collect_return = On
; Collect parameters
Xdebug.collect_params = On
; Tracking format
Xdebug.trace_format = 0
; output folder
Xdebug.trace_output_dir=/tmp/xdebug
; Output file name format
Xdebug.trace_output_name = trace.%c.%p
; Turn on analyzer
Xdebug.profiler_enable = On
; Output path
Xdebug.profiler_output_dir =/tmp/xdebug
; Output file name format
Xdebug.profiler_output_name = cachegrind.out.%p
; Log Memory usage
Xdebug.show_mem_delta = On

Configured values can be queried using Php-i|grep xdebug after configuration is complete


Windows System xdebug Module installation


1, go to www.xdebug.org download the corresponding version of the PHP module file, save the downloaded file to the PHP ext directory, you can modify the name of the file, such as Save as: Xdebug-2.0.0rc1.dll
2, modify the 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 with Extension=xdebug-2.0.0rc1.dll way, it must be loaded in ZEND way, or after installation, phpinfo printed out of the Xdebug segment will have must LOADED as ZEND Extension warning message (for unknown reason).

Xdebug.auto_trace=on;
Automatically turn on the "monitor function call process" mode. This function can output the monitoring information of a function call as a file in the directory you specify. The default value for this configuration item is off.

Xdebug.collect_params=on;
Open the function that collects "function parameters". The parameter values of the function call are included in the monitoring information for the Function procedure call. The default value for this configuration item is off.

Xdebug.collect_return=on
Open the function that collects the function return value. The return value of the function is included in the monitoring information of the Function procedure call. The default value for this configuration item is off.

Xdebug.trace_output_dir= "C:/temp/xdebug"
; Sets the path of the output file for the function call monitoring information.

Xdebug.profiler_enable=on
; Open the Performance Monitor.

Xdebug.profiler_output_dir= "C:/temp/xdebug";
Set the path of the performance monitoring information output file.

There are some more specific parameter settings, see: http://www.xdebug.org/docs-settings.php

3. Restart Apache

This way, when you run PHP locally, you will generate some debugging information in the directory you set:

function call process monitoring information file filename format: trace.xxxxxx.xt. This file can be viewed directly, containing information such as the time the function was run, the parameter value of the function call, the return value, the file and location. The content format is still relatively straightforward.
File name format for performance monitoring files: 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, installation Wincachegrind
Because the performance monitoring file: The contents of the Cachegrind.out.xxxxxxxx file are not easily understood by humans, we need a tool to read it. There is a software like this in Windows: Wincachegrind.
1, to http://sourceforge.net/projects/wincachegrind/download installation Wincachegrind
2, after the installation run, 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, my machine all the functions of PHP after the operation of the call process monitoring information is written to a trace.xxxxxx.xt, which talent if you know to point to the Ming Road

http://www.bkjia.com/PHPjc/632848.html www.bkjia.com true http://www.bkjia.com/PHPjc/632848.html techarticle What is Xdebug? It is a can be used to debug PHP code to run a tool, the following small section to introduce Xdebug installation method, the following tutorial is based on Linux and Windows system OH. ...

  • 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.