> 백엔드 개발 > PHP 튜토리얼 > PHP调试凶器Xdebug安装配置教程

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

WBOY
풀어 주다: 2016-06-13 11:16:30
원래의
915명이 탐색했습니다.

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

  作者:zhanhailiang 日期:2013-03-11
로그인 후 복사

1.简述

引用官方描述:

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

2.安装配置教程

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

3.测试用例

简单的测试用例如下:

<span class="kw2" style="color:rgb(0,0,0); font-weight:bold"><?php</span><span class="kw3" style="color:rgb(0,0,102)">header</span><span class="br0" style="color:rgb(102,204,102)">(</span> <span class="st_h">'X-Test: Testing'</span> <span class="br0" style="color:rgb(102,204,102)">)</span><span class="sy0" style="color:rgb(102,204,102)">;</span><span class="kw3" style="color:rgb(0,0,102)">setcookie</span><span class="br0" style="color:rgb(102,204,102)">(</span> <span class="st0" style="color:rgb(255,0,0)">"TestCookie"</span><span class="sy0" style="color:rgb(102,204,102)">,</span> <span class="st0" style="color:rgb(255,0,0)">"test-value"</span> <span class="br0" style="color:rgb(102,204,102)">)</span><span class="sy0" style="color:rgb(102,204,102)">;</span><span class="kw3" style="color:rgb(0,0,102)">var_dump</span><span class="br0" style="color:rgb(102,204,102)">(</span> xdebug_get_headers<span class="br0" style="color:rgb(102,204,102)">(</span><span class="br0" style="color:rgb(102,204,102)">)</span> <span class="br0" style="color:rgb(102,204,102)">)</span><span class="sy0" style="color:rgb(102,204,102)">;</span>
로그인 후 복사

输出如下:

<span class="kw3" style="color:rgb(0,0,102)">array</span><span class="br0" style="color:rgb(102,204,102)">(</span><span class="nu0" style="color:rgb(204,102,204)">2</span><span class="br0" style="color:rgb(102,204,102)">)</span> <span class="br0" style="color:rgb(102,204,102)">{</span>  <span class="br0" style="color:rgb(102,204,102)">[</span><span class="nu0" style="color:rgb(204,102,204)">0</span><span class="br0" style="color:rgb(102,204,102)">]</span> <span class="sy0" style="color:rgb(102,204,102)">=></span>  string<span class="br0" style="color:rgb(102,204,102)">(</span><span class="nu0" style="color:rgb(204,102,204)">15</span><span class="br0" style="color:rgb(102,204,102)">)</span> <span class="st0" style="color:rgb(255,0,0)">"X-Test: Testing"</span>  <span class="br0" style="color:rgb(102,204,102)">[</span><span class="nu0" style="color:rgb(204,102,204)">1</span><span class="br0" style="color:rgb(102,204,102)">]</span> <span class="sy0" style="color:rgb(102,204,102)">=></span>  string<span class="br0" style="color:rgb(102,204,102)">(</span><span class="nu0" style="color:rgb(204,102,204)">33</span><span class="br0" style="color:rgb(102,204,102)">)</span> <span class="st0" style="color:rgb(255,0,0)">"Set-Cookie: TestCookie=test-value"</span><span class="br0" style="color:rgb(102,204,102)">}</span>
로그인 후 복사

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

<span class="re0" style="color:rgb(0,0,255)">$a</span> <span class="sy0" style="color:rgb(102,204,102)">=</span> <span class="kw3" style="color:rgb(0,0,102)">array</span><span class="br0" style="color:rgb(102,204,102)">(</span><span class="nu0" style="color:rgb(204,102,204)">1</span><span class="sy0" style="color:rgb(102,204,102)">,</span> <span class="nu0" style="color:rgb(204,102,204)">2</span><span class="sy0" style="color:rgb(102,204,102)">,</span> <span class="nu0" style="color:rgb(204,102,204)">3</span><span class="br0" style="color:rgb(102,204,102)">)</span><span class="sy0" style="color:rgb(102,204,102)">;</span><span class="re0" style="color:rgb(0,0,255)">$b</span> <span class="sy0" style="color:rgb(102,204,102)">=&</span> <span class="re0" style="color:rgb(0,0,255)">$a</span><span class="sy0" style="color:rgb(102,204,102)">;</span><span class="re0" style="color:rgb(0,0,255)">$c</span> <span class="sy0" style="color:rgb(102,204,102)">=&</span> <span class="re0" style="color:rgb(0,0,255)">$a</span><span class="br0" style="color:rgb(102,204,102)">[</span><span class="nu0" style="color:rgb(204,102,204)">2</span><span class="br0" style="color:rgb(102,204,102)">]</span><span class="sy0" style="color:rgb(102,204,102)">;</span> xdebug_debug_zval<span class="br0" style="color:rgb(102,204,102)">(</span><span class="st_h">'a'</span><span class="br0" style="color:rgb(102,204,102)">)</span><span class="sy0" style="color:rgb(102,204,102)">;</span>
로그인 후 복사

输出如下:

a<span class="sy0" style="color:rgb(102,204,102)">:</span> <span class="br0" style="color:rgb(102,204,102)">(</span>refcount<span class="sy0" style="color:rgb(102,204,102)">=</span><span class="nu0" style="color:rgb(204,102,204)">2</span><span class="sy0" style="color:rgb(102,204,102)">,</span> is_ref<span class="sy0" style="color:rgb(102,204,102)">=</span><span class="nu0" style="color:rgb(204,102,204)">1</span><span class="br0" style="color:rgb(102,204,102)">)</span><span class="sy0" style="color:rgb(102,204,102)">=</span><span class="kw3" style="color:rgb(0,0,102)">array</span><span class="br0" style="color:rgb(102,204,102)">(</span><span class="nu0" style="color:rgb(204,102,204)">3</span><span class="br0" style="color:rgb(102,204,102)">)</span> <span class="br0" style="color:rgb(102,204,102)">{</span>  <span class="br0" style="color:rgb(102,204,102)">[</span><span class="nu0" style="color:rgb(204,102,204)">0</span><span class="br0" style="color:rgb(102,204,102)">]</span> <span class="sy0" style="color:rgb(102,204,102)">=></span><span class="br0" style="color:rgb(102,204,102)">(</span>refcount<span class="sy0" style="color:rgb(102,204,102)">=</span><span class="nu0" style="color:rgb(204,102,204)">1</span><span class="sy0" style="color:rgb(102,204,102)">,</span> is_ref<span class="sy0" style="color:rgb(102,204,102)">=</span><span class="nu0" style="color:rgb(204,102,204)">0</span><span class="br0" style="color:rgb(102,204,102)">)</span><span class="sy0" style="color:rgb(102,204,102)">=</span>  int<span class="br0" style="color:rgb(102,204,102)">(</span><span class="nu0" style="color:rgb(204,102,204)">1</span><span class="br0" style="color:rgb(102,204,102)">)</span>  <span class="br0" style="color:rgb(102,204,102)">[</span><span class="nu0" style="color:rgb(204,102,204)">1</span><span class="br0" style="color:rgb(102,204,102)">]</span> <span class="sy0" style="color:rgb(102,204,102)">=></span><span class="br0" style="color:rgb(102,204,102)">(</span>refcount<span class="sy0" style="color:rgb(102,204,102)">=</span><span class="nu0" style="color:rgb(204,102,204)">1</span><span class="sy0" style="color:rgb(102,204,102)">,</span> is_ref<span class="sy0" style="color:rgb(102,204,102)">=</span><span class="nu0" style="color:rgb(204,102,204)">0</span><span class="br0" style="color:rgb(102,204,102)">)</span><span class="sy0" style="color:rgb(102,204,102)">=</span>  int<span class="br0" style="color:rgb(102,204,102)">(</span><span class="nu0" style="color:rgb(204,102,204)">2</span><span class="br0" style="color:rgb(102,204,102)">)</span>  <span class="br0" style="color:rgb(102,204,102)">[</span><span class="nu0" style="color:rgb(204,102,204)">2</span><span class="br0" style="color:rgb(102,204,102)">]</span> <span class="sy0" style="color:rgb(102,204,102)">=></span><span class="br0" style="color:rgb(102,204,102)">(</span>refcount<span class="sy0" style="color:rgb(102,204,102)">=</span><span class="nu0" style="color:rgb(204,102,204)">2</span><span class="sy0" style="color:rgb(102,204,102)">,</span> is_ref<span class="sy0" style="color:rgb(102,204,102)">=</span><span class="nu0" style="color:rgb(204,102,204)">1</span><span class="br0" style="color:rgb(102,204,102)">)</span><span class="sy0" style="color:rgb(102,204,102)">=</span>  int<span class="br0" style="color:rgb(102,204,102)">(</span><span class="nu0" style="color:rgb(204,102,204)">3</span><span class="br0" style="color:rgb(102,204,102)">)</span><span class="br0" style="color:rgb(102,204,102)">}</span>
로그인 후 복사

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

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿