1、安裝 xdebug
使用 phpinfo 輸出關於php的配置信息,將此信息複製到 php版本對應的xdebug分析頁 ,按照官方提示下載對應的xdebug版本,將下載的擴展文件移動到擴展目錄,然後修改 php.ini 文件,在文件最後添加以下代碼後,刷新 phpinfo ,就可以看到xdebug的相關配置信息。
[xdebug]
zend_extension=php_xdebug.dll #對應的擴展文件名
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host= localhost
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
2、配置 phpstrom
- 進入File>Settings>PHP>Debug,看到XDebug選項卡,port填9000,其他默認
- 進入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 PHPSTORM,host 填localhost,port 填80
- 打開phpStorm,進入File>Settings>PHP>Servers,這裏要填寫服務器端的相關信息,name填localhost,host填localhost,port填80,debugger選XDebug
- 進入Run> edit configurations,點+號,Server選填localhost,start url 是在http://localhost的基礎上再加上去,如加上 test,就形成http://localhost/test
- 在phpStorm裏打開監聽,設置程序段點,點擊綠色的debug爬蟲按鈕,chrome瀏覽器打開xdebug頁,phpStorm出現debug窗口,可以看到下面的debug信息,配置成功