Rumah  >  Artikel  >  pembangunan bahagian belakang  >  PHP调试凶器Xdebug安装配置教程

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

WBOY
WBOYasal
2016-06-13 11:16:30876semak imbas

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】

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:CI框架源码翻阅-Input.phpArtikel seterusnya:CI框架源码阅览-Security.php