PHP 開發環境搭建( Eclipse PDT XAMPP XDEBUG)

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 

Php.ini 配置代碼  收藏代碼
  1. ;載入Xdebug  
  2. zend_extension_ts="c:/xampplite/php/ext/php_xdebug.dll"  
  3.   
  4. ;xdebug配置  
  5. [Xdebug]  
  6. ;開啓自動跟蹤  
  7. xdebug.auto_trace = On  
  8. ;開啓異常跟蹤  
  9. xdebug.show_exception_trace = On  
  10. ;開啓遠程調試自動啓動  
  11. xdebug.remote_autostart = On  
  12. ;開啓遠程調試  
  13. xdebug.remote_enable = On  
  14. ;收集變量  
  15. xdebug.collect_vars = On  
  16. ;收集返回值  
  17. xdebug.collect_return = On  
  18. ;收集參數  
  19. 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,在最後增加:  

Httpd.conf代碼  收藏代碼
  1. Alias /proj1  E:/pdt-ws/proj1/  
  2. Alias /proj1/ E:/pdt-ws/proj1/  
  3. <Directory "E:/pdt-ws/proj1/">  
  4.     Options Indexes FollowSymLinks Includes ExecCGI  
  5.     AllowOverride All  
  6.     Order allow,deny  
  7.     Allow from all    
  8. </Directory>    

 重啓apache

 

回到eclipse pdt,右擊index.php,

選擇 Debug As --> PHP Web Page 就可以進行斷點調試了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章