美文网首页
PHPstorm+Xdebug 断点调试

PHPstorm+Xdebug 断点调试

作者: 渔岛钟情 | 来源:发表于2019-04-10 13:33 被阅读0次

一 . 下载扩展 xdebug

选择对应版本 方式一

  • 注意: 通过phpinfo() 查看php参数:


    image.png
  1. x86 :32位的扩展库,即使你的计算机是64位,也要下载x86的扩展
  2. NTS : 非安全线程, 下载时候注意看清,标题中不会出现TS字样.
  3. VC15 : windows的运行库;

如上图的php参数,选择:


image.png

选择对应版本 方式二

打开网站 https://xdebug.org/wizard.php
将phpinfo网页的源代码拷贝到文本框中,网站将自动分辨出php版本对应的Xdebug,直接下载即可
但是: 千万不要使用最新版本,坑多....

二 . 配置php.ini

将下载好的xdebug.dll 扩展,放至php/ext 扩展目录,并复制path;

// 需要其他功能请 去掉注释,
//  修改php.ini
[XDebug]

xdebug.profiler_output_dir="I:\Tools\phpstudy\PHPTutorial\tmp\xdebug"
xdebug.trace_output_dir="I:\Tools\phpstudy\PHPTutorial\tmp\xdebug"
// 每次debug都会写入日志文件,一般不用开启,在配置debug时,可开启以便查看配置时出现的错误!
;xdebug.remote_log="I:\Tools\phpstudy\PHPTutorial\tmp\xdebug\xdebug.log"
zend_extension="I:\Tools\phpstudy\PHPTutorial\php\php-7.2.1-nts\ext\php_xdebug-2.6.1-7.2-vc15-nts.dll"
;设置此参数 无需加 XDEBUG_SESSION_START= {xdebug.idekey},请求
;开启远程调试自动启动
;xdebug.remote_autostart=1
;开启远程调试
xdebug.remote_enable=on
xdebug.remote_port=9001
;xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.idekey=PHPSTORM
xdebug.var_display_max_depth=30
xdebug.remote_connect_back=On
;开启自动跟踪
xdebug.auto_trace=On
;开启异常跟踪
;xdebug.show_exception_trace = On
;收集变量
;xdebug.collect_vars = On
;收集返回值
;xdebug.collect_return = On
;收集参数
;xdebug.collect_params = On
;xdebug.profiler_enable=On

保存 && 重启 php

三 . 配置phpstorm

xdebug中的端口必须与php.ini 中的 remote_port 相同


图 xdebug

图 DBGP 链接中:
IDE key 需与 php.ini 中 idekey 相同

图 DBGP 链接

图 servers中
host: 为你的虚拟机域名或者Ip
port: 你的项目配置在nginx的端口
debugger : 默认Xdebug
name: 为新建的server取个名字

图 servers

图 run/debug config:

  1. 从右上角箭头处点击下拉,选择Edit Configurations ,
  2. 点击 +号 新建 PHP Web Page
  3. name 为当前配置命名
    server: 选择刚刚 [图 servers] 中配置好的server
  4. 点击ok 保存;


    图 run/debug config

1 点击 监听器 启动监听,
2 点击溴虫 开始断点审查;


image.png

OVER

相关文章

网友评论

      本文标题:PHPstorm+Xdebug 断点调试

      本文链接:https://www.haomeiwen.com/subject/mgrniqtx.html