PHP xdebug Configuration and installation Method _php Tutorial

Source: Internet
Author: User
Xdebug is a PHP debugging tool, we can use like echo,print and so on to invoke the error, but we have no way to check the function execution times and execution time, and the use of xdebug can be fully implemented Oh, let me introduce in Winodws PHP Xdebug configuration and installation process.

We have to go to the official website download Download php_xdebug.dll,2. Place the downloaded Php_xdebug.dll in the PHP installation directory Phpext, and then edit the php.ini file

The code is as follows Copy Code

[Xdebug]
Zend_extension = "/home/ad/php/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
Xdebug.auto_trace = On
Xdebug.auto_profile = On
Xdebug.collect_params = On
Xdebug.collect_return = On
Xdebug.profiler_enable = On
Xdebug.trace_output_dir = "/home/ad/xdebug_log"
Xdebug.profiler_output_dir = "/home/ad/xdebug_log"

4. Restart Apache.
5. Write a test.php, content , if you see Xdebug in the output content, the installation configuration is successful. Or go to the/home/ad/xdebug_log to see if the logs are out.

PHP Xdebug configuration information

Xdebug section configuration Options Description

Xdebug.auto_trace = 1

Whether to allow Xdebug trace function calls, trace information is stored as a file, the default value is 0

Collect_params = 1

Whether the Xdebug trace function parameter is allowed, the default value is 0

Xdebug.collect_return = 1

Whether the Xdebug trace function return value is allowed, the default value is 0

xdebug.profiler_enable = 1

Open Xdebug Performance Analyzer, stored as a file, this configuration cannot be configured with the Ini_set () function, the default value is 0

Xdebug.profiler_output_dir

Where the profiling file is stored, the default value is/tmp

Xdebug.profiler_output_name

A naming convention for profiling files, with a default value of cachegrind.out.%p

Xdebug.trace_output_dir

function call trace information output file directory, default value is/tmp

Xdebug.trace_output_name

function call trace information output file naming convention, default is trace.%c

Setting options

Category Setting Description

Log

Xdebug.trace_output_dir

Log Trace Output Directory
Xdebug.trace_output_name Log file name, Xdebug provides a series of identifiers, generate the appropriate format of the file name, please refer to the official website
Xdebug.trace_options The record is added to the file by: 1 = append (if the file exists). 0 (default) = Overwrite (if the file exists)
Show data Xdebug.collect_params Non-0 value = parameter display option for control function
  • 0 = not displayed.
  • 1 = parameter type, value (for example: Array (9)).
  • 2 = Ibid. 1, only slightly different in CLI mode
  • 3 = ALL variable contents
  • 4 = all variable contents and variable names (for example: Array (0 = 9)).
Xdebug.collect_return 1 = function return value is displayed. Default 0 does not display
Xdebug.collect_vars 1 = shows which variables are used in the current scope, displays the variable name, does not record the value of the variable, and, if necessary, uses the Xdebug.collect_params
Xdebug.collect_assignments 1 = Add a row to display the variable assignment (if 1, the shape is $ A = 1; this type of assignment expression is displayed in the trace file)
Format Xdebug.trace_format
  • 0 = Human readable. From left to right each column represents: Point in time, memory, memory difference (need to set xdebug.show_mem_delta=1), rank, function name, function parameter (need to set, Xdebug.collect_params=1, as long as non-0), the current code line is located in the file name, Line number.
  • 1 = machine readable [1]. Need to use third-party apps, such as: Xdebug trace file parser or Xdebug trace viewer
  • 2 = HTML format is table, open with browser, show table
Xdebug.show_mem_delta 1 = Show memory consumption per function call (Memory difference)
Behavior Xdebug.auto_trace 1 = Turn on auto-tracking. (There are 2 ways of tracking, one is auto-tracking, all PHP scripts run, will produce trace files, the other is the trigger mode tracking, such as the following)
XDEBUG.TRACE_ENABLE_TRIGGER[2]

1 = use xdebug_trace get/post to trigger tracing, or xdebug_trace by setting a cookie. To avoid each request, the corresponding trace trace file is generated and you need to set the Auto_trace to 0

Note: This feature can only be set in the 2.2+ version

[Xdebug-general] Re:is Trace_enable_trigger defunct?

Limit Xdebug.var_display_max_depth Array and object element display depth: Mainly used in array nesting, when object attributes are nested, the element content of the levels is displayed. Default 3.
Xdebug.var_display_max_data How long the variable value is displayed when it is a string. Default 512.
Xdebug.var_display_max_children The number of arrays and object elements to display. Default 128

Some custom functions

Function Description
void Xdebug_enable () Open manually, equivalent to Xdebug.default_enable=on
void Var_dump () Overwrite PHP provided var_dump, error, display function stack information, (premise: PHP.ini html_errors is 1), use xdebug.overload_var_dump set whether overwrite
void Xdebug_start_trace (
String Trace_file_path
[, integer options])
Manual control of code snippets that need to be traced
Trace_file_path: File path (relative or absolute, if empty). If empty, or do not pass the parameter, use the Xdebug.trace_output_dir set directory
Options:
  • xdebug_trace_append:1 = Append file content end, 0 = overwrite the file
  • Xdebug_trace_computerized:
    • 2 = same as xdebug.trace_format=1.
  • Xdebug_trace_html:4 = output HTML table, browser open as a table
void Xdebug_stop_trace () Stop tracking, code tracking stops on that line
String Xdebug_get_tracefile_name () Get the output file name, used in conjunction with Xdebug.auto_trace.
void Xdebug_var_dump ([mixed var[,...]) Output variable details, the equivalent of PHP var_dump, the specific display please see here
Xdebug.show_local_vars The default is 0, not displayed, or nonzero, when PHP performs an error, displays all local variables in the scope of the error code (note: This generates a lot of information, so the default is closed), which shows the difference as [3]
Array Xdebug_get_declared_vars () To display declared variables in the current scope
Array Xdebug_get_code_coverage () Show which lines the code executes within a section of code [4]

http://www.bkjia.com/PHPjc/632850.html www.bkjia.com true http://www.bkjia.com/PHPjc/632850.html techarticle Xdebug is a PHP debugging tool, we can use like echo,print and so on to invoke the error, but we have no way to check the function execution times and execution time, and the use of Xdebug ...

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