1、下載xdebug模塊 (https://xdebug.org/)
注意:帶"ts"是線程安全的意思,"nts"的他沒有標示,也就是說,如果是nts的要下載沒標示的,下載下來的文件名其實是有標示的。
使用xdebug官方提供的一個檢測工具:https://xdebug.org/wizard.php
這里就把phpinfo()的信息使用輸出出來(注意:使用輸出函數,比如var_dump()),然后就會檢測你的可以下載對應的版本,如下圖:
配置php.ini配置文件(這里需要注意一點,找對了php.ini文件),在網頁上打印出phpinfo()的信息,查看這一條信息:
Loaded Configuration File D:\phpStudy\php\php-7.0.12-nts\php.ini
[xdebug]
zend_extension ="D:/phpStudy/php/php-7.0.12-nts/ext/php_xdebug-2.6.1-7.0-vc14-nts.dll"
xdebug.remote_enable = On
;啟用性能檢測分析
xdebug.profiler_enable = On
;啟用代碼自動跟蹤
xdebug.auto_trace=On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
;指定性能分析文件的存放目錄
xdebug.profiler_output_dir ="D:/phpStudy/tmp"
xdebug.show_local_vars=0
;配置端口和監聽的域名
xdebug.remote_port=9000
xdebug.remote_host="localhost"
在phpStorm里打開監聽,就是一個電話一樣的按鈕,點擊變為綠色,在程序代碼點前點擊,設置程序段點,點擊綠色的debug爬蟲按鈕,chrome瀏覽器打開xdebug頁,phpStorm出現debug窗口,並獲取到variables值,即為看到下面的debug信息,說明成功配置。圖13
12 斷點調試
通過點擊紅框中的位置設置和取消斷點