Table of Contents
Setting Options
Some custom functions
Home Backend Development PHP Tutorial Detailed explanation of PHP XDebug configuration and installation method_PHP tutorial

Detailed explanation of PHP XDebug configuration and installation method_PHP tutorial

Jul 13, 2016 am 10:47 AM
php xdebug and Install tool us method yes of Detailed explanation debug Configuration

XDebug is a debugging tool for PHP. We can use echo, print, etc. to call errors, but our functions cannot check the number of function executions and execution time. This can be achieved using XDebug. Let me introduce the configuration and installation process of php XDebug in winodws.

We first go to the official website to 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"

[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 with the content of . If xdebug is seen in the output content, the installation and configuration are successful. Or go to /home/ad/xdebug_log to see if the log has come out.

Detailed explanation of PHP XDebug configuration and installation method_PHP tutorial

PHP Xdebug configuration information

Explanation of some Xdebug configuration options

xdebug.auto_trace = 1

Whether to allow Xdebug to trace function calls. The tracking information is stored in a file. The default value is 0

collect_params = 1

Whether to allow Xdebug to track function parameters, the default value is 0

xdebug.collect_return = 1

Whether to allow Xdebug to track function return values, the default value is 0

xdebug.profiler_enable = 1

Open the xdebug performance analyzer and store it in file form. This configuration cannot be configured with the ini_set() function. The default value is 0

xdebug.profiler_output_dir

The storage location of the performance analysis file. The default value is /tmp

xdebug.profiler_output_name

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

xdebug.trace_output_dir

Function call tracking information output file directory, the default value is /tmp

xdebug.trace_output_name

Function call trace information output file naming rules, the default is trace.%c

Setting Options

Category Setting Description

Log

xdebug.trace_output_dir

Log tracking output directory
xdebug.trace_output_name Log file name, xdebug provides a series of identifiers to generate file names in corresponding formats. For details, please refer to the official website
xdebug.trace_options How records are added to the file: 1 = Append (if the file exists). 0 (default) = Overwrite (if the file exists)
Show data xdebug.collect_params Non-zero value = Controls the parameter display options of the function
  • 0 = Do not display.
  • 1 = parameter type, value (for example: array(9)).
  • 2 = Same as 1, but 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 = Display function return value. Default 0 does not display
xdebug.collect_vars 1 = Show which variables are used in the current scope and display the variable name. This option will not record the value of the variable. If necessary, use xdebug.collect_params
xdebug.collect_assignments 1 = Add a line to display variable assignment (if it is 1, it will be in the form $a = 1; this type of Assignment Expression will be displayed in the trace file)
Format xdebug.trace_format
  • 0 = human readable. Each column from left to right represents: time point, memory, memory difference (needs to set xdebug.show_mem_delta=1), level, function name, function parameters (needs to set, xdebug.collect_params= 1, as long as it is non-zero), the file name of the current code line, and the line number.
  • 1 = machine readable[1]. Need to use third-party app, such as: xdebug trace file parser or xdebug trace viewer
  • 2 = html format, that is, table, open with browser, display table
xdebug.show_mem_delta 1 = Display memory consumption (memory difference) of each function call
Behavior xdebug.auto_trace 1 = Turn on automatic tracking. (There are two tracking methods, one is automatic tracking, all php scripts will generate trace files when running; the other is triggered tracking, as follows)
xdebug.trace_enable_trigger[2]

1 = Use XDEBUG_TRACE GET/POST to trigger tracing, or set the cookie XDEBUG_TRACE. To avoid generating corresponding trace files for each request, you need to set auto_trace to 0

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

[xdebug-general] Re: Is trace_enable_trigger defunct?

Restrictions xdebug.var_display_max_depth Display depth of array and object elements: Mainly used when nesting arrays and object attributes to display several levels of element content. Default 3.
xdebug.var_display_max_data How long to display when the variable value is a string. Default 512.
xdebug.var_display_max_children The number of array and object elements displayed. Default 128

Some custom functions

Function Description
void xdebug_enable() 手动打开,相当于xdebug.default_enable=on
void var_dump() 覆写php提供的var_dump,出错时,显示函数堆栈信息,(前提:php.ini里html_errors为1),使用xdebug.overload_var_dump 设置是否覆写
void xdebug_start_trace( 
string trace_file_path 
[, integer options] )
手动控制需要追踪的代码段
trace_file_path :文件路径(相对或绝对,若为空).如果为空,或者不传参, 使用xdebug.trace_output_dir设置的目录
options :
  • XDEBUG_TRACE_APPEND: 1 = 追加文件内容末尾, 0 = 覆写该文件
  • XDEBUG_TRACE_COMPUTERIZED:
    • 2 =同 xdebug.trace_format=1 .
  • XDEBUG_TRACE_HTML: 4 = 输出HTML表格,浏览器打开为一table
void xdebug_stop_trace() 停止追踪,代码追踪在该行停止
string xdebug_get_tracefile_name() 获得输出文件名,与 xdebug.auto_trace配合使用.
void xdebug_var_dump([mixed var[,...]])  输出变量详细信息,相当于php里的var_dump,具体显示请看这里
xdebug.show_local_vars  默认为0,不显示;非零时,在php执行出错时,显示出错代码所在作用域所有本地变量(注:这会产生大量信息,因此默认是closed),具体显示差别如下图[3]
array xdebug_get_declared_vars() 显示当前作用域中已声明的变量
array xdebug_get_code_coverage() 显示某一段代码内,代码执行到哪些行[4]
Function Description void xdebug_enable() Open manually, 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 override void xdebug_start_trace( string trace_file_path [, integer options] ) Manually control the code segments that need to be traced
trace_file_path: file path (relative or absolute, if empty). If it is empty, or no parameters are passed, use the directory set by xdebug.trace_output_dir options:
  • XDEBUG_TRACE_APPEND: 1 = append to the end of the file content, 0 = overwrite the file
  • XDEBUG_TRACE_COMPUTERIZED:
    • 2 =Same as xdebug.trace_format=1.
  • XDEBUG_TRACE_HTML: 4 = Output an HTML table and open it as a table in the browser
void xdebug_stop_trace() Stop tracking, code tracking stops at this line string xdebug_get_tracefile_name() Get the output file name, used with xdebug.auto_trace. void xdebug_var_dump([mixed var[,...]]) Output variable details, equivalent to var_dump in php, please see here for specific display xdebug.show_local_vars The default is 0 and is not displayed; when it is non-zero, when an error occurs in PHP execution, all local variables in the scope of the error code are displayed (Note: This will generate a lot of information, so the default is closed). The specific display difference is as follows [ 3] array xdebug_get_declared_vars() Display declared variables in the current scope array xdebug_get_code_coverage() Show which lines of code are executed in a certain section of code[4] http://www.bkjia.com/PHPjc/632850.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632850.htmlTechArticleXDebug is a debugging tool for PHP. We can use echo, print, etc. to call errors, but Our functions have no way to check the number of function executions and execution time, but using XDebug...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

How to efficiently integrate Node.js or Python services under LAMP architecture? How to efficiently integrate Node.js or Python services under LAMP architecture? Apr 01, 2025 pm 02:48 PM

Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

How to configure apscheduler timing task as a service on macOS? How to configure apscheduler timing task as a service on macOS? Apr 01, 2025 pm 06:09 PM

Configure the apscheduler timing task as a service on macOS platform, if you want to configure the apscheduler timing task as a service, similar to ngin...

In LangChain, how do I use AgentExecutor to replace the disabled initialize_agent function? In LangChain, how do I use AgentExecutor to replace the disabled initialize_agent function? Apr 01, 2025 pm 04:18 PM

How to replace the disabled initialize_agent function in LangChain? In the LangChain library, initialize_agent...

Can Python parameter annotations use strings? Can Python parameter annotations use strings? Apr 01, 2025 pm 08:39 PM

Alternative usage of Python parameter annotations In Python programming, parameter annotations are a very useful function that can help developers better understand and use functions...

Can the Python interpreter be deleted in Linux system? Can the Python interpreter be deleted in Linux system? Apr 02, 2025 am 07:00 AM

Regarding the problem of removing the Python interpreter that comes with Linux systems, many Linux distributions will preinstall the Python interpreter when installed, and it does not use the package manager...

How to ensure high availability of MongoDB on Debian How to ensure high availability of MongoDB on Debian Apr 02, 2025 am 07:21 AM

This article describes how to build a highly available MongoDB database on a Debian system. We will explore multiple ways to ensure data security and services continue to operate. Key strategy: ReplicaSet: ReplicaSet: Use replicasets to achieve data redundancy and automatic failover. When a master node fails, the replica set will automatically elect a new master node to ensure the continuous availability of the service. Data backup and recovery: Regularly use the mongodump command to backup the database and formulate effective recovery strategies to deal with the risk of data loss. Monitoring and Alarms: Deploy monitoring tools (such as Prometheus, Grafana) to monitor the running status of MongoDB in real time, and

PostgreSQL monitoring method under Debian PostgreSQL monitoring method under Debian Apr 02, 2025 am 07:27 AM

This article introduces a variety of methods and tools to monitor PostgreSQL databases under the Debian system, helping you to fully grasp database performance monitoring. 1. Use PostgreSQL to build-in monitoring view PostgreSQL itself provides multiple views for monitoring database activities: pg_stat_activity: displays database activities in real time, including connections, queries, transactions and other information. pg_stat_replication: Monitors replication status, especially suitable for stream replication clusters. pg_stat_database: Provides database statistics, such as database size, transaction commit/rollback times and other key indicators. 2. Use log analysis tool pgBadg

See all articles