0

0

PHP调试凶器Xdebug安装配置教程

php中文网

php中文网

发布时间:2016-06-13 11:16:30

|

1036人浏览过

|

来源于php中文网

原创

PHP调试利器Xdebug安装配置教程

  作者:zhanhailiang 日期:2013-03-11

1.简述

引用官方描述:

The Xdebug extension helps you debugging your script by providing a lot of valuable debug information.

2.安装配置教程

# 下载xdebug安装包linux-06bq:/data/software/ # wget http://xdebug.org/files/xdebug-2.2.1.tgzlinux-06bq:/data/software/ # tar zxvf xdebug-2.2.1.tgzlinux-06bq:/data/software/ # cd xdebug-2.2.1/ # 编译安装xdebuglinux-06bq:/data/software/xdebug-2.2.1/ # phpizelinux-06bq:/data/software/xdebug-2.2.1/ # ./configure --with-php-config=/usr/local/services/php/bin/php-config --enable-xdebuglinux-06bq:/data/software/xdebug-2.2.1/ # makelinux-06bq:/data/software/xdebug-2.2.1/ # sudo make installInstalling shared extensions:     /usr/local/services/php/lib/php/extensions/no-debug-non-zts-20090626/   +----------------------------------+  |                                                                      |  |   INSTALLATION INSTRUCTIONS                                          |  |   =========================                                          |  |                                                                      |  |   See http://xdebug.org/install.php#configure-php for instructions   |  |   on how to enable Xdebug for PHP.                                   |  |                                                                      |  |   Documentation is available online as well:                         |  |   - A list of all settings:  http://xdebug.org/docs-settings.php     |  |   - A list of all functions: http://xdebug.org/docs-functions.php    |  |   - Profiling instructions:  http://xdebug.org/docs-profiling2.php   |  |   - Remote debugging:        http://xdebug.org/docs-debugger.php     |  |                                                                      |  |                                                                      |  |   NOTE: Please disregard the message                                 |  |       You should add "extension=xdebug.so" to php.ini                |  |   that is emitted by the PECL installer. This does not work for      |  |   Xdebug.                                                            |  |                                                                      |  +----------------------------------+linux-06bq:/data/software/xdebug-2.2.1/ # cp /usr/local/services/php/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so /usr/local/services/php/extensions/ # 修改php配置文件################################################################add the following line to php.ini:     zend_extension="/wherever/you/put/it/xdebug.so"     (for non-threaded use of PHP, for example the CLI, CGI or Apache 1.3 module)or:    zend_extension_ts="/wherever/you/put/it/xdebug.so"     (for threaded usage of PHP, for example the Apache 2 work MPM or the the ISAPI module). Note: In case you compiled PHP yourself and used --enable-debug you would have touse zend_extension_debug=. From PHP 5.3 onwards, you always need to use thezend_extension PHP.ini setting name, and not zend_extension_ts, nor zend_extension_debug.However, your compile options (ZTS/normal build; debug/non-debug) still need to matchwith what PHP is using.################################################################linux-06bq:/data/software/xdebug-2.2.1/ # vim /usr/local/services/php/etc/php.ini # zend_extension=/usr/local/services/php/extensions/xdebug.so # 检测xdebug是否加载成功(两种方法,php -m或输出phpinfo()结果)linux-06bq:/data/software/xdebug-2.2.1/ # php -m|grep xdebugxdebuglinux-06bq:/data/software/xdebug-2.2.1/ # php -r "phpinfo();" |grep xdebugxdebugxdebug support => enabledxdebug.auto_trace => Off => Offxdebug.cli_color => 0 => 0xdebug.collect_assignments => Off => Offxdebug.collect_includes => On => Onxdebug.collect_params => 0 => 0xdebug.collect_return => Off => Offxdebug.collect_vars => Off => Offxdebug.coverage_enable => On => Onxdebug.default_enable => On => Onxdebug.dump.COOKIE => no value => no valuexdebug.dump.ENV => no value => no valuexdebug.dump.FILES => no value => no valuexdebug.dump.GET => no value => no valuexdebug.dump.POST => no value => no valuexdebug.dump.REQUEST => no value => no valuexdebug.dump.SERVER => no value => no valuexdebug.dump.SESSION => no value => no valuexdebug.dump_globals => On => Onxdebug.dump_once => On => Onxdebug.dump_undefined => Off => Offxdebug.extended_info => On => Onxdebug.file_link_format => no value => no valuexdebug.idekey => no value => no valuexdebug.max_nesting_level => 100 => 100xdebug.overload_var_dump => On => Onxdebug.profiler_aggregate => Off => Offxdebug.profiler_append => Off => Offxdebug.profiler_enable => Off => Offxdebug.profiler_enable_trigger => Off => Offxdebug.profiler_output_dir => /tmp => /tmpxdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%pxdebug.remote_autostart => Off => Offxdebug.remote_connect_back => Off => Offxdebug.remote_cookie_expire_time => 3600 => 3600xdebug.remote_enable => Off => Offxdebug.remote_handler => dbgp => dbgpxdebug.remote_host => localhost => localhostxdebug.remote_log => no value => no valuexdebug.remote_mode => req => reqxdebug.remote_port => 9000 => 9000xdebug.scream => Off => Offxdebug.show_exception_trace => Off => Offxdebug.show_local_vars => Off => Offxdebug.show_mem_delta => Off => Offxdebug.trace_enable_trigger => Off => Offxdebug.trace_format => 0 => 0xdebug.trace_options => 0 => 0xdebug.trace_output_dir => /tmp => /tmpxdebug.trace_output_name => trace.%c => trace.%cxdebug.var_display_max_children => 128 => 128xdebug.var_display_max_data => 512 => 512xdebug.var_display_max_depth => 3 => 3OLDPWD => /data/software/xdebug-2.2.1_SERVER["OLDPWD"] => /data/software/xdebug-2.2.1 # 最后重启服务器或php-fpm即可(根据当前服务器加载PHP模式而定)

3.测试用例

简单的测试用例如下:

header( 'X-Test: Testing' );setcookie( "TestCookie", "test-value" );var_dump( xdebug_get_headers() );

输出如下:

array(2) {  [0] =>  string(15) "X-Test: Testing"  [1] =>  string(33) "Set-Cookie: TestCookie=test-value"}

高级测试用例——查看变量的zval值

$a = array(1, 2, 3);$b =& $a;$c =& $a[2]; xdebug_debug_zval('a');

输出如下:

a: (refcount=2, is_ref=1)=array(3) {  [0] =>(refcount=1, is_ref=0)=  int(1)  [1] =>(refcount=1, is_ref=0)=  int(2)  [2] =>(refcount=2, is_ref=1)=  int(3)}

开始Xdebug之旅吧,少年!【Documentation for: Xdebug 2】

相关文章

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载

相关标签:

php

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

相关专题

更多
ip地址修改教程大全
ip地址修改教程大全

本专题整合了ip地址修改教程大全,阅读下面的文章自行寻找合适的解决教程。

33

2025.12.26

压缩文件加密教程汇总
压缩文件加密教程汇总

本专题整合了压缩文件加密教程,阅读专题下面的文章了解更多详细教程。

18

2025.12.26

wifi无ip分配
wifi无ip分配

本专题整合了wifi无ip分配相关教程,阅读专题下面的文章了解更多详细教程。

46

2025.12.26

漫蛙漫画入口网址
漫蛙漫画入口网址

本专题整合了漫蛙入口网址大全,阅读下面的文章领取更多入口。

91

2025.12.26

b站看视频入口合集
b站看视频入口合集

本专题整合了b站哔哩哔哩相关入口合集,阅读下面的文章查看更多入口。

283

2025.12.26

俄罗斯搜索引擎yandex入口汇总
俄罗斯搜索引擎yandex入口汇总

本专题整合了俄罗斯搜索引擎yandex相关入口合集,阅读下面的文章查看更多入口。

370

2025.12.26

虚拟号码教程汇总
虚拟号码教程汇总

本专题整合了虚拟号码接收验证码相关教程,阅读下面的文章了解更多详细操作。

35

2025.12.25

错误代码dns_probe_possible
错误代码dns_probe_possible

本专题整合了电脑无法打开网页显示错误代码dns_probe_possible解决方法,阅读专题下面的文章了解更多处理方案。

25

2025.12.25

网页undefined啥意思
网页undefined啥意思

本专题整合了undefined相关内容,阅读下面的文章了解更多详细内容。后续继续更新。

72

2025.12.25

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
AngularJS教程
AngularJS教程

共24课时 | 2.1万人学习

CSS3实现按钮特效视频教程
CSS3实现按钮特效视频教程

共15课时 | 3.2万人学习

细说PHP第三季
细说PHP第三季

共58课时 | 11.1万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号