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

來源:互聯網
上載者:User

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 就可以進行斷點調試了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.