MacOS下postman和phpstorm断点调试
MacOS下postman和phpstorm断点调试
一、安装xdebug
- 下载 xdebug文件
将phpinfo()的在浏览器中输出的源代码复制到文本框中,xdebug会提示如何配置和下载哪个版本 的xdebug。
附:全部下载地址
二、修改PHP配置文件
- 在php.ini末尾加上如下代码
[xdebug]
zend_extension="/file_path/xdebug.so" #file_path是指具体路径
xdebug.auto_trace=on #启用代码自动跟踪
xdebug.collect_params=on #允许收集传递给函数的参数变量
xdebug.collect_return=on #允许收集函数调用的返回值
xdebug.trace_output_dir="/path/xdebug" #指定堆栈跟踪文件的存放目录
xdebug.profiler_enable=on #是否启用Xdebug的性能分析,并创建性能信息文件
xdebug.profiler_output_dir="/path/xdebug" #指定性能分析信息文件的输出目录
xdebug.remote_enable = On #是否开启远程调试
xdebug.remote_handler = "dbgp" #指定远程调试的处理协议
xdebug.remote_mode = "req"
xdebug.remote_host = "localhost" #指定远程调试的主机名
xdebug.remote_port = 9000 #指定远程调试的端口号
xdebug.idekey = PHPSTORM #指定传递给DBGp调试器处理程序的IDE Key
三、配置PHPStorm
-
打开PHPStrom->Preferences->Languages & Frameworks->PHP
-
打开PHPStrom->Preferences->Languages & Frameworks->PHP- >Debug
-
打开PHPStrom->Preferences->Languages & Frameworks->PHP- >Debug->DBGp Proxy
-
打开PHPStrom->Preferences->Languages & Frameworks->PHP- >Server
-
设置运⾏行行配置(Run → Edit Configuration)
-
新建一个PHP Web Application
四、配置chrome
- 安装插件xdebug helper
- 安装成功后右击插件图标->选项
- 配置完毕后,打开xdebug
五、配置Postman
- 安装Postman , ⾕谷歌浏览器器中打开应⽤用商店,搜索postman,两个都安装
- postman设置,开启拦截
六、调试
注意!!!
使⽤用Postman调试时
需在请求的API参数中加⼊入⼀一个 XDEBUG_SESSION_START = PHPSTORM
这是为了了告知 你的请求需要触发断点调试