xdebug is a high-level tool for PHP code execution. It can very well test the performance of each stage of our PHP code, so that we can optimize the code in a timely manner. Now I will give you the configuration of xdebug and xdebug debugging skills. .
windows xdebug configuration installation
1. Download Xdebug
Download address: http://xdebug.org/download.php
The latest version is 2.1.2. There are many versions, including the difference between 32-bit and 64-bit, the difference between VC6 and VC9, and the difference between thread safety and not
Save to test.php, and open the saved server directory through the browser. Find Compiler (if not, it is VC6), Architecture (if not, look at the value of Configure Command) and Thread Safety in the front Info. As shown below, you should download 32-bit VC9 thread-safe (PHP 5.3 VC9 TS (32 bit))
2. Install Xdebug
If you have already configured PHP, rename the downloaded file to php_xdebug.dll (it doesn’t matter if you don’t change it, just to look better), and put down the ext folder in the PHP installation directory.
3. Configure Xdebug
Xdebug has many configuration items, and I only know a few of them, so I will only talk about the commonly used ones. Modify the php.ini file in the PHP installation directory and insert the following code at the end of the file:
[Xdebug]
The code is as follows |
Copy code |
代码如下 |
复制代码 |
zend_extension="E:APMServPHPextphp_xdebug.dll"
xdebug.auto_trace=On
;自动跟踪设置最好在最前面设置,要不然不会开启
xdebug.profiler_enable=on
xdebug.trace_output_dir="E:APMServxdebug"
xdebug.profiler_output_dir="E:APMServxdebug"
;最大递归数
xdebug.max_nesting_level=100
;重写var_dump()
xdebug.overload_var_dump = On
;当这个参数被设置为1时,即使捕捉到异常,xdebug仍将强制执行异常跟踪当一个异常出现时
xdebug.show_exception_trace=1
xdebug.show_local_vars = 1
xdebug.collect_params=On
xdebug.collect_return=On
xdebug.collect_vars=On
xdebug.dump_undefined=On
xdebug.profiler_enable_trigger=On
;允许远程连接
xdebug.remote_enable=true
;允许远程连接的zs IDE的ip地址
xdebug.remote_host=192.168.0.51
;zendstudio 设定的端口
xdebug.remote_port=9000
;zendstudio 的应用层通信协议
xdebug.remote_handler=dbgp
xdebug.extended_info="1"
|
zend_extension="E:APMServPHPextphp_xdebug.dll"
xdebug.auto_trace=On
;It is best to set the automatic tracking setting at the front, otherwise it will not be turned on
xdebug.profiler_enable=on
xdebug.trace_output_dir="E:APMServxdebug"
xdebug.profiler_output_dir="E:APMServxdebug"
;Maximum number of recursions
xdebug.max_nesting_level=100
;Rewrite var_dump()
代码如下 |
复制代码 |
wget http://www.xdebug.org/files/xdebug-2.2.3.tgz
tar xzf xdebug-2.2.3.tgz
cd xdebug-2.2.3
/usr/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
|
xdebug.overload_var_dump = On
; When this parameter is set to 1, even if an exception is caught, xdebug will still force exception tracking when an exception occurs
xdebug.show_exception_trace=1
xdebug.show_local_vars = 1
xdebug.collect_params=On
xdebug.collect_return=On
xdebug.collect_vars=On
xdebug.dump_undefined=On
xdebug.profiler_enable_trigger=On
;Allow remote connections
xdebug.remote_enable=true
;The IP address of zs IDE that allows remote connection
xdebug.remote_host=192.168.0.51
;Port set by zendstudio
xdebug.remote_port=9000
;zendstudio’s application layer communication protocol
xdebug.remote_handler=dbgp
xdebug.extended_info="1"
|
Because I don’t want to have a Log file (because the file grows very fast, it will be one or two gigabytes in less than two days), so I commented out trace_output_dir and profiler_output_dir. It should be noted that Xdebug will not automatically create a directory, and you must ensure that the set directory is is actually there. As for the other several values, they are all default values, so they are noted out. Because they may be changed, they are listed here. Now refresh the phpinfo() page and you should be able to see the Xdebug information.
linux xdebug configuration installation
xdebug is a module of php that needs to be compiled and installed. I installed php using lnmp. php is installed to /usr/local/php by default, and then makes a hard link to /usr/bin
Compile xdebug first
The code is as follows |
Copy code |
wget http://www.xdebug.org/files/xdebug-2.2.3.tgz
tar xzf xdebug-2.2.3.tgz
cd xdebug-2.2.3
/usr/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
|
Modify php.ini configuration
Add the following
The code is as follows
代码如下 |
复制代码 |
;no-debug-non-zts-20090626 这个文件夹名称和php版本是一一对应的
zend_extension= "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.default_enable = On
xdebug.show_exception_trace = On
xdebug.show_local_vars = 1
xdebug.max_nesting_level = 50
xdebug.var_display_max_depth = 6
xdebug.dump_once = On
xdebug.dump_globals = On
xdebug.dump_undefined = On
xdebug.dump.REQUEST = *
xdebug.cli_color = 2
|
|
Copy code
|
| ;no-debug-non-zts-20090626 This folder name corresponds to the php version one-to-one
zend_extension= "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.default_enable = On
xdebug.show_exception_trace = On
xdebug.show_local_vars = 1
xdebug.max_nesting_level = 50
xdebug.var_display_max_depth = 6
xdebug.dump_once = On
xdebug.dump_globals = On
xdebug.dump_undefined = On
xdebug.dump.REQUEST = *
xdebug.cli_color = 2
Restart php-fpm, write any php code with errors, refresh the browser, and you will see the error message
http://www.bkjia.com/PHPjc/629820.htmltruehttp: //www.bkjia.com/PHPjc/629820.htmlTechArticlexdebug is a high-level tool for PHP code execution. It can test the performance of each stage of our PHP code very well. In this way, we can optimize the code in a timely manner. Let me tell you...