本地環境phpStorm10+XDebug配置和斷點調試

http://www.cnblogs.com/xujian2016/p/5548921.htmlphp

 

安裝環境:XAMPP;phpStorm版本10; windows 7 64bit。html

XAMPP、phpStorm 都直接安裝在了D盤根目錄,9999m目錄建在D:\xampp\htocts下,即目錄工程文件夾路徑爲D:\xampp\htocts\9999m。在phpStorm>File>open,找到9999m,點擊肯定,加載9999m到了phpStorm(安裝環境路徑根據須要自行更改,後面的配置內容也相似)。chrome

 

1.      開始服務器端配置:安裝好XAMPP,中止apache服務(注意,若是直接退出XAMPP,是不會中止apache的)。apache

2.      在安裝目錄下找到php.ini,相似於D:\xampp\php\php.ini,並打開。windows

3.      找到被註釋掉的項目(去掉前面的?)並按以下設置:瀏覽器

[XDebug]服務器

==============原代碼app

xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir ="D:\phpStudy\tmp\xdebug"
xdebug.trace_output_dir ="D:\phpStudy\tmp\xdebug"
xdebug.profiler_output_name = "cache.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
;zend_extension="D:\phpStudy\php53n\ext\xdebug.dll"
框架

==============改後phpstorm

xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir ="D:\phpStudy\tmp\xdebug"
xdebug.trace_output_dir ="D:\phpStudy\tmp\xdebug"
xdebug.profiler_output_name = "cache.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
zend_extension="D:\phpStudy\php53n\ext\xdebug.dll"
xdebug.idekey= PHPSTROM

====================轉載的

zend_extension = "D:\xampp\php\ext\php_xdebug.dll"

xdebug.profiler_append = 0

xdebug.profiler_enable = 1

xdebug.profiler_enable_trigger = 0

xdebug.profiler_output_dir = "D:\xampp\tmp"

xdebug.profiler_output_name = "cachegrind.out.%t-%s"

xdebug.remote_enable = on

xdebug.remote_handler = "dbgp"

xdebug.remote_host = "127.0.0.1"

xdebug.trace_output_dir = "D:\xampp\tmp"

xdebug.idekey= PHPSTROM   

 

最初的設置是這樣的:圖2

 

;的意思是被註釋掉了,因此要先去掉;號;

而後開啓xdebug.remote_enable = on;

還要增長xdebug.idekey= PHPSTROM。

 

其中remote_host 是指調試客戶端的地址,即IDE所在的IP,同理remote_port 是客戶端的端口,這兩項在遠程調試的狀況下注意修改,遠程的時候最終改成:

 

[XDebug]

zend_extension = "D:\xampp\php\ext\php_xdebug.dll"

xdebug.profiler_append = 0

xdebug.profiler_enable = 1

xdebug.profiler_enable_trigger = 0

xdebug.profiler_output_dir = "D:\xampp\tmp"

xdebug.profiler_output_name = "cachegrind.out.%t-%s"

xdebug.remote_enable = 1

xdebug.remote_handler = "dbgp"

xdebug.remote_mode = "req"

xdebug.remote_port = 9000

 

4.      保存文件,從新啓動apache檢查是否成功開啓了xdebug服務。

 

 一種方法爲在CMD裏輸入D:\xampp\php\php.exe -m 看到XDebug,說明成功開啓XDebug。

 

另外一種方法爲瀏覽器打開localhost,找到phpinfo()點擊打開配置狀況,查找xdebug項,找到了說明xdebug配置成功。

 

至此,服務器端配置完畢。

 

 

5.      下面是客戶端調試。打開phpStorm,進入File>Settings>PHP(文件-設置-語言和框架-php),這裏要interpreter瀏覽,填D:\xampp\php\php.exe,自動識別版本。

 

6.      進入File>Settings>PHP>Servers,這裏要填寫服務器端的相關信息,name填localhost,

  ,host填localhost,port填80,debugger選XDebug。圖7 是自定義的虛擬域名。

 

7.      進入File>Settings>PHP>Debug,看到XDebug選項卡,port填9000,其餘默認。圖8

 

 

8.      進入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 PHPSTORM,host 填localhost,port填9000,點OK退出設置。圖9

 

 

9.      進入Run> Debug configurations,點+號,Server選填localhost,start url 是在http://localhost的基礎上再加上去,如加上 9999m,就造成http://localhost/9999m.

以圖中藍色地址爲參考, Browse 填chrome,點OK退出設置。圖10

 

 

點OK退出設置以後,phpstorm運行按鈕旁邊自動填充localhost,且運行按鈕由灰色被激活成爲綠色。若是start url填的是http://localhost,沒有填寫9999m,則當點擊phpstorm運行按鈕,瀏覽器進入默認地址http://localhost,沒辦法直接訪問http://localhost/9999m

 

 

 

10.   chrome瀏覽器連接配置。找到對應的插件,chrome的爲phpstrom IDE Support chrome.crx,本身下載而後拖動文件到chrome設置>擴展程序。

 

 

  

Chrome右上角增長了JB圖標即爲成功安裝插件。

 

 

 

11.   在phpStorm裏打開監聽,就是一個電話同樣的按鈕,點擊變爲綠色,在程序代碼點前點擊,設置程序段點,點擊綠色的debug爬蟲按鈕,chrome瀏覽器打開xdebug頁,phpStorm出現debug窗口,並獲取到variables值,即爲看到下面的debug信息,說明成功配置。圖13

 

 

12 斷點調試

 

 經過點擊紅框中的位置設置和取消斷點

 

 

 

 

大功告成!!!

  參考文獻:http://blog.sina.com.cn/zhyl4669

相關文章
相關標籤/搜索