PHP调试凶器Xdebug安装配置教程
程序员文章站
2022-05-15 16:44:26
...
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.tgz linux-06bq:/data/software/ # tar zxvf xdebug-2.2.1.tgz linux-06bq:/data/software/ # cd xdebug-2.2.1/ # 编译安装xdebug linux-06bq:/data/software/xdebug-2.2.1/ # phpize linux-06bq:/data/software/xdebug-2.2.1/ # ./configure --with-php-config=/usr/local/services/php/bin/php-config --enable-xdebug linux-06bq:/data/software/xdebug-2.2.1/ # make linux-06bq:/data/software/xdebug-2.2.1/ # sudo make install Installing 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 to use zend_extension_debug=. From PHP 5.3 onwards, you always need to use the zend_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 match with 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 xdebug xdebug linux-06bq:/data/software/xdebug-2.2.1/ # php -r "phpinfo();" |grep xdebug xdebug xdebug support => enabled xdebug.auto_trace => Off => Off xdebug.cli_color => 0 => 0 xdebug.collect_assignments => Off => Off xdebug.collect_includes => On => On xdebug.collect_params => 0 => 0 xdebug.collect_return => Off => Off xdebug.collect_vars => Off => Off xdebug.coverage_enable => On => On xdebug.default_enable => On => On xdebug.dump.COOKIE => no value => no value xdebug.dump.ENV => no value => no value xdebug.dump.FILES => no value => no value xdebug.dump.GET => no value => no value xdebug.dump.POST => no value => no value xdebug.dump.REQUEST => no value => no value xdebug.dump.SERVER => no value => no value xdebug.dump.SESSION => no value => no value xdebug.dump_globals => On => On xdebug.dump_once => On => On xdebug.dump_undefined => Off => Off xdebug.extended_info => On => On xdebug.file_link_format => no value => no value xdebug.idekey => no value => no value xdebug.max_nesting_level => 100 => 100 xdebug.overload_var_dump => On => On xdebug.profiler_aggregate => Off => Off xdebug.profiler_append => Off => Off xdebug.profiler_enable => Off => Off xdebug.profiler_enable_trigger => Off => Off xdebug.profiler_output_dir => /tmp => /tmp xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p xdebug.remote_autostart => Off => Off xdebug.remote_connect_back => Off => Off xdebug.remote_cookie_expire_time => 3600 => 3600 xdebug.remote_enable => Off => Off xdebug.remote_handler => dbgp => dbgp xdebug.remote_host => localhost => localhost xdebug.remote_log => no value => no value xdebug.remote_mode => req => req xdebug.remote_port => 9000 => 9000 xdebug.scream => Off => Off xdebug.show_exception_trace => Off => Off xdebug.show_local_vars => Off => Off xdebug.show_mem_delta => Off => Off xdebug.trace_enable_trigger => Off => Off xdebug.trace_format => 0 => 0 xdebug.trace_options => 0 => 0 xdebug.trace_output_dir => /tmp => /tmp xdebug.trace_output_name => trace.%c => trace.%c xdebug.var_display_max_children => 128 => 128 xdebug.var_display_max_data => 512 => 512 xdebug.var_display_max_depth => 3 => 3 OLDPWD => /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全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
- 玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
- 天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
- 最新文章
- 热门排行
推荐阅读
-
PHP开发环境配置(MySQL数据库安装图文教程)
-
php配置xdebug插件,断点调试
-
PHPStorm+Xdebug断点远程调试PHP xdebug安装
-
在win系统安装配置 Memcached for PHP 5.3 图文教程
-
php Xdebug 调试扩展的安装与使用.
-
Eclipse中php插件安装及Xdebug配置的使用详解
-
[视频教程] 配置vscode的PHP自动补全提示与使用Xdebug进行远程调试debug
-
WIN2003+IIS6 PHP 5.3.8安装配置教程[图文]
-
阿里云Windows 2008一键安装包配置php web环境图文安装教程(IIS+Php+Mysql)
-
Windows和Linux中php代码调试工具Xdebug的安装与配置详解
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论