PhpStorm+xdebug+postman调试

 写PHP时,一直用postman做测试,最近发现在测试过程中可以用xdebug来断点调试,比原来手动打exit或者die来断点效率高多了。

   下面记录下我自己从安装到测试的全部详细过程。我的运行环境是:windows+wamp

   一.配置wamp安装目录下的php.ini文件

我的安装目录是:C:\wamp64\bin\apache\apache2.4.23\bin

 

zend_extension ="c:/wamp64/bin/php/php5.6.31/zend_ext/php_xdebug-2.5.5-5.6-vc11-x86_64.dll"
xdebug.remote_enable = on
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.show_local_vars=0
xdebug.remote_handler = dbgp
;设置xdebug的端口为9001
xdebug.remote_port = 9001
;设置idekey
xdebug.idekey="PHPSTORM"

二.在配置具体的项目之前,我们先配置好PhpStorm默认设置(default setting),避免每次建立项目都要进行的重复操作。

1.打开PhpStorm,点击左上角File → Default Setting → Languages & Frameworks → PHP 如图:

 

2.弹出interpreters窗口

 

3.添加页面

 

4.正常情况下,配置好之后会显示xdebug版本

 

5.设置xdebug端口号

 

6.设置 DBGp Proxy

 

 7.设置Servers,点击绿色的“+”配置一个新的Server  

  

三.接下来设置运行配置(Run → Edit Configuration),具体操作如下

   1.点击右上角,如图

   

 2.设置默认的PHP web application配置

 

3.新建一个php web application

 

4.设置好断点并开始调试

 

 

注意:将此时浏览器的弹出框上面显示的网址,复制到postman

 

5.调试成功,按F9快捷键跳到下一个断点如图:

 

猜你喜欢

转载自blog.csdn.net/aa19891204/article/details/83019225