admin管理员组文章数量:1564627
最近在提升PHP开发效率 ,var_dump 和 echo 这种调试方式只适合新手
想看谷歌浏览器调试的朋友先跟着下面配置搞好,跳过postman,直接看谷歌浏览器
postman和谷歌浏览器 配置xdebug和phpstrom方式是一样的
以下为配置步骤
1.安装xdebug扩展,根据自己的phpinfo环境下载
x86是32位,x64是64位,不要搞错,很多朋友觉得自己的电脑是64位,就去直接下载64位,
phpinfo一直不显示xdebug,以下为我的截图,php分nts 和ts版本的注意区分
xdebug下载官网 Xdebug: Downloads
安装好xdebug的截图
需要加php.ini的配置
xdebug 2版本的配置
zend_extension="D:\phpstudy\PHPTutorial\php\php-7.2.1-nts\ext\php_xdebug-2.9.0-7.2-vc15-nts.dll"
xdebug.profiler_enable=1
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir="D:\phpstudy\PHPTutorial\tmp\xdebug"
xdebug.trace_output_dir="D:\phpstudy\PHPTutorial\tmp\xdebug"
xdebug.profiler_output_name="xdebug.cache.%t-%s"
xdebug.profiler_append=0
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9001
xdebug.remote_handler="dbgp"
xdebug.idekey=PHPSTORM
配置项详解:
-
zend_extension
:填写你下载的 Xdebug 扩展本机所在绝对路径 -
xdebug.profiler_enable
:0 为关闭,1 为开启 -
xdebug.profiler_enable_trigger
: 有关触发器的设置,写 0 即可 -
xdebug.profiler_output_dir
:Xdebug 日志记录的地址 -
xdebug.trace_output_dir
:同xdebug.profiler_output_dir
,配置请填写一致 -
xdebug.profiler_output_name
: 日志输出格式,按照我写就行 -
xdebug.profiler_append
: 关于附加设置,具体未知,默认填 0 即可 -
xdebug.remote_enable
: 远程调试功能,0 关闭,1 开启,只要是与浏览器联调,请开启此功能 -
xdebug.remote_host
: 联调的 URL 主机地址 -
xdebug.remote_port
: 联调的请求端口,如果本机 9001 未被占用,请如此设置即可 -
xdebug.remote_handler
:调试函数,默认 dbgp,不要对其修改 -
xdebug.idekey
:与 PhpStorm 连接时的确认口令,默认 PHPSTORM
xdebug 3配置
zend_extension=php_xdebug-3.0.4-7.2-vc15-nts.dll
xdebug.remote_enable=1
xdebug.mode = debug,develop
xdebug.start_with_request = yes
xdebug.client_port=9003
xdebug.client_host=127.0.0.1
xdebug.remote_handler = dbgp
xdebug.idekey=PHPSTORM
2.配置PHPSTROM
2-1 设置 PHP CLI,如下截图,配置你正在使用的php.exe
配置路径 File->Settings
2-2 设置 Xdebug 端口
2-3 设置 PhpStorm Key、主机以及端口
2-4 新建 Xdebug 服务,Name 可以根据自己项目名称来取
2-5 配置 Xdebug 调试接口 菜单路径 Run->Edit Configurations
以上操作意味着配置完成
3.测试使用postman
3-1开启phpstorm监听
没有开启监听请求前的按钮状态
下图为开启后的状态
3-2 postman headers 需要加参数 COOKIE=XDEBUG_SESSION=PHPSTORM
3-3 我的调试结果
PHPstrom+xdebug + postman的调试原理
1.xdebug为php的调试扩展,可以详细打印php的变量信息
2.postman需要在headers里使用cookie参数,COOKIE=XDEBUG_SESSION=PHPSTORM
3.通过postman的请求参数phpstorm就可以监听到来自postman的请求,
4,.通过已经安装好的xdebug扩展和设置的断点,phpstrom把xdebug记录的变量信息,格式化的显示在编辑器上。
有问题可以到Q裙721200119找我,我是群主
以下为谷歌浏览器调试方式
注意网络和谐问题,可以到裙里联系我
1.安装xdebug helper
2.配置xdebug helper,选择ide key phpstorm 其他的可以不用管
3.安装 jetbrains ide suppurt
4.配置 jetbrains ide suppurt
这里配置的port 和上面php.ini配置的端口保持一致
5.通过浏览器测试请求 断点调试
剩下的就是自己打断点调试了
有任何PHP的问题可以到Q裙721200119找我交流,我是群主
版权声明:本文标题:PHPstrom + xdebug + postman断点调试代码 php谷歌浏览器代码断点调试 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1727515524a1118331.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论