phpstorm安装xdebug调试插件
2019-08-06 本文已影响0人
最底层的技术渣
前言:
特别注意:
一、
xdebug
会提示不支持php7
以下的版本(要自行选择)
二、如果安装了此插件,在安装wordpress
这种类型的开源平台时会报错,解决办法参考 ==> 报错mysqli_init():属性访问不允许
1、下载对应版本的xdebug
xdebug官网下载地址
你需要仔细分析和选择要下载的对应版本,否则无法调试。由于非常容易出错,建议采用下面这种简单方法:
1.1xdebug网站提供一个自动分析你系统对应的xdebug版本的页面,网址是 https://xdebug.org/wizard.php

1.2在页面中需要粘贴进去php版本信息,也就是phpinfo()
函数的信息,如下图:

1.3ctrl+A
全选这个页面的信息,然后粘贴到第一个图片的页面中。

1.4点击 analyse my phpinfo() output
按钮
- 下载php_xdebug-2.7.2-7.2-vc15-nts.dll
- 将下载的文件移动到
F:\phpStudy\PHPTutorial\php\php-7.2.1-nts\ext
- 编辑
F:\phpStudy\PHPTutorial\php\php-7.2.1-nts\php.ini
并添加该行
zend_extension = F:\phpStudy\PHPTutorial\php\php-7.2.1-nts\ext\php_xdebug-2.7.2-7.2-vc15-nts.dll
重新启动Web服务器
图1-4 找到你需要下载的xdebug版本
1.5到此为止,xdebug
的下载和启用就完成了,重新运行 phpinfo.php
文件

2、修改php.ini配置
;指定xdebug库文件的绝对路径
zend_extension = F:\phpStudy\PHPTutorial\php\php-7.2.1-nts\ext\php_xdebug-2.7.2-7.2-vc15-nts.dll
;开启远程调试,连接和监听主机和端口的调试客户端
xdebug.remote_enable = On
;启用代码自动跟踪
xdebug.auto_trace=On
;允许收集传递给函数的参数变量
xdebug.collect_params=1
;允许收集函数调用的返回值
xdebug.collect_return=On
;客户机ip
xdebug.remote_host="127.0.0.1"
;客户机xdebug监听端口和调试协议
xdebug.remote_port=9000
;启动调试器协议dbgp
xdebug.remote_handler=dbgp
;指定DBGP调试器(IDE)处理程序区分大小写
xdebug.idekey="PHPSTORM"
;启用性能检测分析
xdebug.profiler_enable = On
;关闭性能检测分析触发器
xdebug.profiler_enable_trigger = off
;指定性能分析文件的存放目录
;xdebug.profiler_output_dir = "d:\tmp"
;指定性能分析文件的名称
;xdebug.profiler_output_name = cachegrind.out.%t.%p
;指定堆栈跟踪文件的存放目录
;xdebug.trace_output_dir="d:\tmp"
;指定堆栈跟踪文件的名称
;xdebug.trace_output_name = trace.%c
栗子
情况一:只在IDE下调试
; 如果要开启IDE下调试
zend_extension = "E:\phpstudy_pro\Extensions\php\php5.6.9nts\ext\php_xdebug-2.5.5-5.6-vc11-nts-x86_64.dll"
情况二:只在浏览器下调试基本操作
; 如果要开启浏览器下调试 remote_enable默认是关闭
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=127.0.0.1
调试
介绍下实际DEBUG过程中PHPSTORM面板的按钮都是做什么用的。当你启动监听后,你将会看到如下图

根据上图图标位置,以x,y坐标的方式描述每个图标的功能。
图标 | 位置 (x,y) | 功能 |
---|---|---|
![]() |
0,0 | 重新执行DEBUG (Rerun test.php) |
![]() |
0,1 | 跳转到原调试文件 (Show execution point) |
![]() |
0,2 | 跳到下一行 (Step over) |
![]() |
0,3 | 执行下一步 (Step info) |
![]() |
0,4 | 跳入库、构造函数等方法或类中 (Force Step Info) |
![]() |
0,5 | 执行函数体或类方法,如果在最外层则结束本次调试 (Step out) |
![]() |
0,6 | 跳到当前节点的下个断点 (Run to Cursor) |
![]() |
0,7 | 执行修改变量或返回的结果用于二次调试(Evaluate arbitrary expression) |
![]() |
0,8 | 显示值的地址 (Show Values Addresses) |
![]() |
0,9 | 是否显示空的值 , 默认是不显示 |
![]() |
0,10 | 跳到下个断点 (Add method to skip list) |
![]() |
1,0 | 重新执行DEBUG (Resume Program) |
![]() |
2,0 | 停止DEBUG(Step process) |
![]() |
3,0 | 查看和管理所有的断点 ( View and manage all breakpoints) |
![]() |
4,0 | 忽略所有断点 (Mute breakpoints) |