Windows下 PHPStorm + XDebug + Po
2019-05-16 本文已影响0人
aoshi
版本介绍:
Windows 环境
PHPStorm 1.8.0 2017.1
一、配置PHP
1.php 安装 xDebug 扩展 下载地址:https://xdebug.org/download.php TS (代表开启线程安全),可查看phpinfo (thread safe 是否开启)
2.下载之后,将扩展放到php的扩展目录( ext/ )
3.修改 php的配置文件 php.ini
[XDebug]
xdebug.profiler_output_dir="D:\phpStudy\tmp\xdebug"
xdebug.trace_output_dir="D:\phpStudy\tmp\xdebug"
xdebug.profiler_enable=1
xdebug.remote_enable=1
xdebug.remote_port=9001
xdebug.idekey="PHPSTORM"
xdebug.remote_host="xcxlocal.baertt.com"
zend_extension="D:\phpStudy\php\php-5.4.45\ext\php_xdebug.dll"
xdebug.profiler_output_dir 日志信息输出目录
xdebug.auto_trace 开启自动跟踪回溯 (默认关闭 off)
xdebug.trace_output_dir 设置回溯信息输出目录
xdebug.profiler_enable=1 开启日志输出
xdebug.remote_enable=1 开启本地
xdebug.remote_port=9001 xdebug 监听端口 不要和fastcgi端口冲突
xdebug.idekey="PHPSTORM" 使用postMan需要传递的cookie参数
zend_extension 扩展地址
可以通过 输出 phpinfo 查看xdebug是否安装成功

也可以通过 cmd 命令 php -m 查看是否有xdebug
二.配置PHPSTORM
1.【File】->【Settings】->【Languages & Frameworks】->【PHP】的servers中配置xdebug服务。

2.弹出interpreters窗口

3.添加页面

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

5.设置xdebug端口号

6.设置 DBGp Proxy

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

三.接下来设置运行配置(Run → Edit Configuration),具体操作如下
1.点击右上角,如图

2.添加PHP web application配置

四、设置postman
1.在请求头里添加 idekey配置

Cookie : XDEBUG_SESSION=PHPSTORM 改配置需要和phpstorm里 settings DBGP proxy 中的 IDE key 一致
五、开始调试
1.开启监听按钮 (如果更新 phpstorm 配置,需要重新开启关闭监听)

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

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