PHPXDebug configuration and installation methods _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHPXDebug configuration and installation methods. XDebug is a debugging tool for php. we can use echo, print, and so on to call errors. However, these functions cannot check the number of function executions and execution time, XDebug is a debugging tool of php. we can call errors such as echo and print, but these functions cannot check the number of function executions and execution time, XDebug can be fully implemented. next I will introduce the php XDebug configuration and installation process in winodws.

Go to the official website to download php_xdebug.dll, 2. put the downloaded php_xdebug.dll to the PHP installation directory phpext, and then edit the php. ini file.

The code is as follows:

[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 file with the content If xdebug is displayed in the output, the installation and configuration are successful. Or go to/home/ad/xdebug_log to check if the log has been generated.

PHP Xdebug configuration information

Configuration options in Xdebug

Xdebug. auto_trace = 1

Whether to allow Xdebug to trace function calls. trace information is stored as files. the default value is 0.

Collect_params = 1

Whether to allow Xdebug to trace function parameters. the default value is 0.

Xdebug. collect_return = 1

Whether to allow Xdebug to trace function return values. the default value is 0.

Xdebug. profiler_enable = 1

Open the xdebug performance analyzer and store it as a file. this configuration cannot be configured using the ini_set () function. the default value is 0.

Xdebug. profiler_output_dir

Storage location of performance analysis files; default value:/tmp

Xdebug. profiler_output_name

Naming rules for performance analysis files. the default value is cachegrind. out. % p.

Xdebug. trace_output_dir

Directory of the output file of the function call trace information. the default value is/tmp.

Xdebug. trace_output_name

Naming rules for output file of function call trace information. the default value is trace. % c.

Set Options

Category Setting Description

Logs

Xdebug. trace_output_dir

Log tracing output Directory
Xdebug. trace_output_name Log file name. xdebug provides a series of identifiers to generate file names in the corresponding format. for details, refer to the official website.
Xdebug. trace_options Method of adding a record to a file: 1 = append (if the file exists). 0 (default) = overwrite (if the file exists)
Show data Xdebug. collect_params Non-zero value = parameter display option for function control
  • 0 = not displayed.
  • 1 = parameter type, value (for example, array (9 )).
  • 2 = same as 1, but slightly different in CLI mode
  • 3 = all variable content
  • 4 = all variable content and variable names (for example, array (0 => 9 )).
Xdebug. collect_return 1 = show function return value. Default 0 not show
Xdebug. collect_vars 1 = display the variables used in the current scope and the variable name. This option does not record the value of the variable. if necessary, use xdebug. collect_params
Xdebug. collect_assignments 1 = add a value for the display variable (for example, $ a = 1; this type of Assignment Expression will be displayed in the trace file)
Format Xdebug. trace_format
  • 0 = readable. each column from left to right indicates the time point, memory, and memory difference (xdebug needs to be set. show_mem_delta = 1), level, function name, function parameter (required, xdebug. collect_params = 1, as long as it is non-zero), the file name of the current code line, row number.
  • 1 = Machine readable [1]. third-party apps are required, such as xdebug trace file parser or xdebug trace viewer.
  • 2 = table in html format. open it in browser and display the table
Xdebug. show_mem_delta 1 = display memory consumption for each function call (memory difference)
Action Xdebug. auto_trace 1 = enable automatic tracing. (there are two tracing methods, one is automatic tracing, all php scripts will generate trace files when running, and the other is trigger tracing, as shown below)
Xdebug. trace_enable_trigger [2]

1 = Use XDEBUG_TRACE GET/POST to trigger tracing, or set cookie XDEBUG_TRACE. to avoid generating corresponding trace Tracing files every time a request is made, you need to set auto_trace to 0

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

[Xdebug-general] Re: Is trace_enable_trigger defunct?

Restrictions Xdebug. var_display_max_depth Array and object element display depth: mainly used in array nesting. When object attributes are nested, several levels of element content are 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 Array and object element display count. Default 128

Some custom functions

Function Description
Void xdebug_enable () Manually open, equivalent to xdebug. default_enable = on
Void var_dump () Overwrite the var_dump provided by php. When an error occurs, the function stack information is displayed (prerequisite: html_errors in php. ini is 1). use xdebug. overload_var_dump to set whether to overwrite data.
Void xdebug_start_trace (
String trace_file_path
[, Integer options])
Manually control the code segment to be tracked
Trace_file_path: the file path (relative or absolute, if empty). if it is empty or no parameter is passed, use the directory set by xdebug. trace_output_dir
Options:
  • XDEBUG_TRACE_APPEND: 1 = End of the append object content, 0 = overwrite the object
  • XDEBUG_TRACE_COMPUTERIZED:
    • 2 = same as xdebug. trace_format = 1.
  • XDEBUG_TRACE_HTML: 4 = output HTML table. open it as a table in the browser.
Void xdebug_stop_trace () Stop Tracing. code tracing stops at this row.
String xdebug_get_tracefile_name () Obtain the output file name, used with xdebug. auto_trace.
Void xdebug_var_dump ([mixed var [,...]) The output variable details are equivalent to var_dump in php. for details, see here.
Xdebug. show_local_vars The default value is 0, not displayed. When an error occurs during php execution, all local variables in the scope of the error code are displayed (note: This will generate a large amount of information, so the default value is closed ), specific display differences are shown in [3]
Array xdebug_get_declared_vars () Display the declared variables in the current scope
Array xdebug_get_code_coverage () Display the lines in a piece of code [4]

...

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.