本地環境 XAMPP+phpStorm+XDebug+chrome 配置和斷點調試


本地環境 XAMPP+phpStorm+XDebug+chrome配置和斷點調試


phpStorm+XAMPP+chrome組合的phpStorm配置XDebug的斷點調試

安裝環境:XAMPP版本號V3.1.0 ;phpStorm版本8.0.3;windowsxp 32bit。您老人家先過目一下,不然怕影響意義。

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

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

 

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

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

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

[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 = on

xdebug.remote_handler = "dbgp"

xdebug.remote_host = "127.0.0.1"

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

xdebug.idekey= PHPSTROM

 

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

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

;的意思是被註釋掉了,所以要先去掉;號;

然後開啓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服務。圖3

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試 一種方法爲在CMD裏輸入D:\xampp\php\php.exe -m 看到XDebug,說明成功開啓XDebug。圖4

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

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

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

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

 

 

5.      下面是客戶端調試。打開phpStorm,進入File>Settings>PHP,這裏要interpreter瀏覽,填D:\xampp\php\php.exe,自動識別版本。圖6

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

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

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

 

7.      進入File>Settings>PHP>Debug,看到XDebug選項卡,port9000,其他默認。圖8

 本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試


8.      進入File>Settings>PHP>Debug>DBGp ProxyIDE key  PHPSTORMhost localhostport9000OK退出設置。圖9

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

 

9.      進入Run> Debug configurations,點+號,Server選填localhoststart urlhttp://localhost/9999m Browse chromeOK退出設置。圖10

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

 

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

 

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

 

10.   chrome瀏覽器鏈接配置。找到對應的插件,chrome的爲phpstrom IDE Support chrome.crx,自己下載然後拖動文件到chrome設置>擴展程序。Chrome右上角增加了JB圖標即爲成功安裝插件。圖12

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

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

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

 

12.        鏈接真心的不錯,http://www.chenxuanyi.cn/xampp-phpstorm-xdebug.html

就是第7步“7.進入File>Settings>PHP>Debug>DBGp ProxyIDE key  PHPSTORMhostlocalhostport 80。”需要改動下port填爲9000。總歸要點100個贊。

本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

 

13.頁面傳圖不讓直接粘貼,所以編個號圖n ,汗吧。你可以先弄好10,其他的次序不要瞎胡變啦就。本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試本地環境 <wbr>XAMPP+phpStorm+XDebug+chrome <wbr>配置和斷點調試

搗鼓着不小心得兩小時多了吧。


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