## 第一课 如何调式PHP代码 > 今天是源码分析视频课程的第一课,今天和大家讲解如何调式PHP代码 > 说到这里,相信很多老司机会说切!调试PHP代码那用得着教, > 我直接echo、var_dump、exit答案就出来了。 > 是的,不可否认你这样调试也是可以的,但前提是你调试是小系统, > 遇到大系统你这样就显得力不从心了! > 今天调试用的工具是phpstorm + xdebug ### 安装xdebug 安装xdebug就不在这里说了,windows 下的很多集成开发工具(wamp,phpstudy) 都带有xdebug扩展了。 ### 1. php xdebug配置: > [XDebug] > zend_extension="D:\phpStudy\php\php-5.6.27-nts\ext\php_xdebug.dll" 扩展路径 > xdebug.remote_enable=On 开启远程调试 > xdebug.remote_port=9001 远程调试PHPSTORM监听的端口号 > xdebug.remote_host=localhost 调试器应该连接到的IP地址 > xdebug.remote_connect_back Default value: 0,如果允许的话,xdebug.remote_host设置将会被失效。取$_SERVER[''REMOTE_ADD']值为远程调试服务器地址 > xdebug.remote_autostart Default value: 0通常情况下,你需要使用指定的HTTP GET/POST变量去激活Xdebug的远程调试功能。当这个设置为1的情况下,Xdebug将在脚本执行时总是尝试去连接调试客户端,即使没有设置GET/POST/COOKIE变量 ### 2. phpstorm配置: 2.1 File->Settings->Languages & Frameworks->PHP->Debug 配置里面的xdebug选择,这里只要设置监听xdedug的端口即可。 2.2 phpstorm左上角edit configurations,进去配置PHP web application PHPSTORM + Xdebug 调调试原理 ![](https://box.kancloud.cn/d4e45b2e6c8a9a8420f10948d4c252a9_582x222.gif) ### 3. 浏览器 firefox 配置 安装相应浏览器扩展,调试更便捷。如firefox中的the easiest xdebug 扩展。 ### 4.开启自动调试模式 xdebug.remote_autostart=On <embed src="http://www.tudou.com/v/weuXqGJJR6Q/&bid=05&resourceId=_05_05_99/v.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="865" height="523"></embed> http://pan.baidu.com/s/1mifUl9u 高清视频下载地址 TP5粉丝群: 543608226 TP5底层答疑群: 451935051