**phpstorm+Xdebug斷點調試PHP**
前言:
何為DEBUG?
相信很多程序員都知道debug這個單詞,也明白它的意思,但是對于這詞的由來,恐怕少有人知道。關于debug的由來,要追溯到1937年。1937年,美國青年霍德華.艾肯找到IBM公司為其投資200萬美元研制計算機,第一臺成品艾肯把它取名為:馬克1號(mark1),又叫“自動序列受控計算機”,從這時起IBM公司由生產制表機,肉鋪磅秤,咖啡研磨機等亂七八糟玩意兒的行業,正式跨進“計算機”領地。為馬克1號編制程序的是哈佛的一位女數學家格蕾絲·莫雷·赫伯,有一天,她在調試程序時出現故障,拆開繼電器后,發現有只飛蛾被夾扁在觸點中間,從而“卡”住了機器的運行。于是,霍波詼諧的把程序故障統稱為“臭蟲(BUG)”,把排除程序故障叫DEBUG,而這奇怪的“稱呼”,后來成為計算機領域的專業行話。從而debug意為程序除錯的意思。
(本文為windows下的安裝流程,mac 版的童鞋可查看:[mac下phpstorm+Xdebug斷點調試PHP](https://blog.csdn.net/ty_hf/article/details/72081965))
官方給出的步驟:
[Zero-configuration Web Application Debugging with Xdebug and PhpStorm](http://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm)
**運行環境:**
PHPSTORM版本 : 8.0.1
PHP版本 : 5.6.2
xdebug版本:php_xdebug-2.2.5-5.6-vc11-x86_64.dll
ps : php版本和xdebug版本一定要相對應
[點擊下載Xdebug](https://xdebug.org/download.php)
1. PHP安裝xdebug擴展
php.ini的配置,下面的配置僅供參考,路徑要換成自己的!
[plain] view plain copy
[xdebug]
zend_extension="D:\wamp\php-5.6.2-x64\ext\php_xdebug-2.2.5-5.6-vc11-x86_64.dll"
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host= localhost
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
ps : remote_handler 、remote_host、remote_port 這些都有默認值,但還是建議設置下,至少知道要設置這些參數~
查看phpinfo~

【或者使用PHPstudy:其他選項菜單/PHP擴展設置/PHP擴展/XDEBUG打上對鉤】
2.PHPSTORM設置
樓主以前一直用zendstudio,剛開始用phpstorm非常蛋疼,用了一段時間后發現還挺好用的~
1.首先檢查phpstorm的xdebug配置
這里的debug port要和php.ini里面的xdebug.remote_port相一致!默認是9000,如果9000端口被占用的話,可以改成其他端口。


phpstorm配置
客戶端調試,打開phpStorm,進入File>Settings>PHP>Servers,這里要填寫服務器端的相關信息,name填localhost,host填localhost,port填80,debugger選XDebug
進入File>Settings>PHP>Debug,看到XDebug選項卡,port填9000,其他默認
進入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 phpStorm,host 填localhost,port 填80
點OK退出設置。

2. 設置debug.


添加本地的 web server~
www.mall.com是我本地的服務



3.開始調試
打好第一個斷點,shift + F9就可以了
打好第一個斷點,選中配置的debug, 按旁邊的臭蟲 按鈕

常見問題:
Debug session was finished without being paused
It may be caused by path mappings misconfiguration or not synchronized local and remote projects.
To figure out the problem check path mappings configuration for 'www.test.com' server at PHP|Servers or enable Break at first line in PHP scripts option (from Run menu).
沒有打斷點或者調試沒有被監測到,碰到這個問題,看看路徑配置對了嗎是否能訪問到
本文地址:http://www.hmoore.net/jinjidexiaofeng/phpstorm_xdebug/560683
注:版權聲明:本文為博主原創文章,轉載請說明出處。 https://blog.csdn.net/ty_hf/article/details/50768702