


Detailed explanation of PHP XDebug configuration and installation method_PHP tutorial
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 | ||||
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.
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
|
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 |
|
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+ |
|
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 :
|
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] |
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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

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

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

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

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

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

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

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
