先下載PHP擴展Xdebug https://xdebug.org, 可以複製自己的phpinfo粘貼到https://xdebug.org/wizard.php中, 會生成需要下載的版本, php.ini的設置語句.
下載好之後放入php目錄的ext文件夾中, 然後設置php.ini, 在最後加上
zend_extension = C:\path\php\ext\php_xdebug-2.4.0rc4-5.6-vc11-x86_64.dll
xdebug.remote_enable =1
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_mode = req
xdebug.remote_port = 9000
xdebug.idekey=PHPSTORM
然後重啓apache, 去設置phpstorm
1. 進入File>Settings>PHP>Servers,這裏要填寫服務器端的相關信息:
name: localhost,
host: localhost,
port: 80,
debugger: XDebug
如果是自定域名則host設置自定域名, 如laravel5.io
2. 進入File>Settings>PHP>Debug,找到XDebug選項卡,port填9000
進入File>Settings>PHP>Debug>DBGp Proxy 填寫:
IDE key: phpStorm
host: localhost
port: 80
設置完畢,點OK退出。
點菜單欄的Run>Edit Configurations… 在彈出的窗口中添加一個調試配置:
點擊左上角加號,選擇PHP Web Application
填寫完畢後,在代碼裏設置斷點, 再開啓電話icno監聽, 點小甲殼蟲啓動調試
再下個瀏覽器插件, xdebug helper, 下載好之後點選項, IDE選PHPSTORM, 不想讓所以網頁顯示小甲蟲, 可以設置domain filter
基本完事了, 調試就點開電話圖標監聽, 設置好斷點, 點小甲蟲開啓調試了, 刷新頁面可見結果