環(huán)境:
- 機器:macbookPro 2015 MacOS Sierra 10.12
- 服務器:appache2.4.23(Mac自帶)
- PHP:php5.6.24
- IDE: PhpStorm 2016.2
安裝 Xdebug:
- 使用 Xdebug 提供的工具(https://xdebug.org/wizard.php)可以獲得 PHP 版本對應的 xdebug 版本君珠,以及安裝教程畜伐。
- 我的在 php.ini中的配置如下
[xdebug]zend_extension="/usr/local/Cellar/php54-xdebug/2.2.5/xdebug.so"
xdebug.remote_enable =1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_mode = "req"
xdebug.remote_port = 9001
xdebug.idekey="PHPSTORM"
配置 PhpStorm:
-
打開 Preferences->Languages&Frameworks->PHP->Debug,找到 Xdebug 選項燎猛,并在 Debug port:中填寫9001.
img_01.png
2.用 PhpStorm 的 RestClient 調(diào)試接口:
-
打開 Tools->Test RESTful WebService
img_02.png -
在 thinkphp 的任意方法里打個斷點,然后點擊調(diào)試按鈕便可進行調(diào)試照皆,如下圖:
img_03.pngimg_04.png
結(jié)語:
- 很長時間了重绷,一直想像調(diào)試安卓、iOS 那樣打斷點進行調(diào)試 PHP,但是一看網(wǎng)上的資料膜毁,感覺很復雜昭卓,就找借口放棄了愤钾。
- 現(xiàn)在配置好了,配和restclient候醒,簡直神器能颁,相比以前ech0 exit 再加個瀏覽器或者 postman 的調(diào)試方式,不知道節(jié)省了多少時間倒淫。
- 其實就是感慨一下伙菊,以前不會用,是多么 多么敌土。镜硕。弱智。不過為時不晚返干。
- 總之兴枯,挺開心的,想分享一下犬金。
- 沒怎么寫博客念恍,語言組織上可能讓人不太好理解。如果哪里又不足晚顷,給我留言哦峰伙。
- 此致 敬禮。