1.下載和安裝配置XAMPP
我下載的是,XAMPP Lite(精簡版) ZIP 壓縮包,下載地址
http://www.apachefriends.org/zh_cn/xampp-windows.html
根據xampp的文檔描述,解壓到根目錄意味着您可以直接使用,不需要先運行“setup_xampp.bat”進行配置
(參見:http://www.apachefriends.org/zh_cn/xampp-windows.html#1721)
所以我的解壓路徑是 C:/xampplite
運行 xampp-control.exe,啓動 apache
訪問 http://localhost/xampp/phpinfo.php
可以看到apache使用的PHP配置文件爲:C:\xampplite\apache\bin\php.ini
打開php.ini,在最後加入以下配置信息,以啓用xdebug
- ;載入Xdebug
- zend_extension_ts="c:/xampplite/php/ext/php_xdebug.dll"
- ;xdebug配置
- [Xdebug]
- ;開啓自動跟蹤
- xdebug.auto_trace = On
- ;開啓異常跟蹤
- xdebug.show_exception_trace = On
- ;開啓遠程調試自動啓動
- xdebug.remote_autostart = On
- ;開啓遠程調試
- xdebug.remote_enable = On
- ;收集變量
- xdebug.collect_vars = On
- ;收集返回值
- xdebug.collect_return = On
- ;收集參數
- xdebug.collect_params = On
重啓apache,後刷新 phpinfo.php 頁面,如果能見到 XDebug 的信息,就說明配置成功
2.安裝配置eclipse pdt
到 http://www.java.com 下載安裝JRE
到 http://www.eclipse.org/pdt/downloads/ 下載 PDT All In Ones
解壓後,運行雙擊eclipse.exe運行pdt,選擇workspace(我的是E:/pdt-ws)
打開window -> perference -> PHP->PHP executables
新增一個executable:
Name: xampplite-php
Executable path: C:\xampplite\php\php.exe
PHP ini file: C:\xampplite\apache\bin\php.ini
PHP Debugger: XDebug
打開window -> perference -> PHP->Debug,設置:
PHP Debuger: XDegug
Server: Default
PHP Executable: xampplite-php
uncheck "Break at first line"
3.調試php項目
新建項目proj1,並新建一個index.php,輸入適當的PHP代碼,然後設一個斷點
打開apache配置文件 httpd.conf,在最後增加:
- Alias /proj1 E:/pdt-ws/proj1/
- Alias /proj1/ E:/pdt-ws/proj1/
- <Directory "E:/pdt-ws/proj1/">
- Options Indexes FollowSymLinks Includes ExecCGI
- AllowOverride All
- Order allow,deny
- Allow from all
- </Directory>
重啓apache
回到eclipse pdt,右擊index.php,
選擇 Debug As --> PHP Web Page 就可以進行斷點調試了