Home > Backend Development > PHP Tutorial > PHP调试凶器Xdebug安装配置教程

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

WBOY
Release: 2016-06-13 12:52:35
Original
945 people have browsed it

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

  作者:zhanhailiang 日期:2013-03-11
Copy after login

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 to
use </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 the
zend_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 match
with 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">
xdebug
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 -r "phpinfo();" |grep xdebug</span><span style="color:#333333">
xdebug
xdebug support =</span><span class="sy0" style="color:rgb(102,204,102)">></span><span style="color:#333333"> enabled
xdebug.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"> Off
xdebug.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"> Off
xdebug.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"> On
xdebug.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"> Off
xdebug.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"> Off
xdebug.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"> On
xdebug.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"> On
xdebug.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 value
xdebug.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 value
xdebug.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 value
xdebug.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 value
xdebug.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 value
xdebug.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 value
xdebug.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 value
xdebug.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 value
xdebug.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"> On
xdebug.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"> On
xdebug.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"> Off
xdebug.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"> On
xdebug.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 value
xdebug.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 value
xdebug.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"> On
xdebug.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"> Off
xdebug.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"> Off
xdebug.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"> Off
xdebug.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"> Off
xdebug.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">tmp
xdebug.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">p
xdebug.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"> Off
xdebug.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"> Off
xdebug.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"> Off
xdebug.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"> dbgp
xdebug.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"> localhost
xdebug.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 value
xdebug.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"> req
xdebug.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"> Off
xdebug.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"> Off
xdebug.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"> Off
xdebug.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"> Off
xdebug.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"> Off
xdebug.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">tmp
xdebug.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">c
xdebug.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>
Copy after login

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>
Copy after login

输出如下:

<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>
Copy after login

高级测试用例――查看变量的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>
Copy after login

输出如下:

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>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template