## 第一課 如何調式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 調調試原理

### 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