zoukankan      html  css  js  c++  java
  • phpstorm配置使用xdebug

    步骤

    1. 配置php.ini,可参考:php开启xdebug扩展及xdebug通信原理

    2. 配置phpstorm

    3. 配置php debug

    4. 进行调试

    配置phpstorm

     

     

     

     

    2.5进行调试

      在需要调试的行上打上断点(点击一下行号后面的空白处即可,再点一次取消断点),需要说明的是当程序运行到该断点时,程序会停留在该行,但该行本身不会执行。自此可以查看程序运行到此处时所包含的所有数据信息。当然,查看信息功能相当于使用php中的var_dump。

       

      操作流程:

     

      打断点—>点击‘虫子’—>点击浏览器页面触发断点—>自动跳转回PhpStorm—>查看携带的数据(调试的目的)—>可按步执行查找问题点—>点击运行(或者F5)—>浏览器页面继续执行—>调试完成。

    附加一篇在window上配置踩过的坑,做个笔记

    环境:windows本机中用虚拟机linux跑的服务

    按照上面流程配置完以后,发现怎么都不生效~~

    首先在配置php.ini时添加调试日志记录

    xdebug.remote_log="/tmp/xdebug.log"

    可以通过日志来跟踪xdebug请求转发是否有误,成功会是下面截图

     之前一直转发不成功,是因为ip配置有误,修改为下面后,正常

    xdebug.remote_host='192.168.110.1'

    这个ip是当前虚拟机的在主机上的ip地址,可通过phpstrom中带有的验证功能来测试排错

    OK,这样通过断点就可以来调试啦~~

    dang....

    每次用phpstorm调试的时候,总会在进入第一个文件的第一行自动打上断点。其次,才会进入到自己设置的断点出。。

    解决方案如下:

    附一个php.ini相关的xdebug配置

    [xdebug]
    ;配置参考:https://segmentfault.com/a/1190000016325041
    ;全部配置:https://xdebug.org/docs/all_settings
    ;指定Xdebug扩展文件的绝对路径    
    zend_extension ="/usr/local/webserver/php-7.3.16/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so"
    ;启用性能检测分析    
    xdebug.profiler_enable=1
    ;启用代码自动跟踪    
    xdebug.auto_trace=on  
    ;允许收集传递给函数的参数变量    
    ;xdebug.collect_params=On  
    ;允许收集函数调用的返回值    
    ;xdebug.collect_return=On  
    ;指定堆栈跟踪文件的存放目录    
    xdebug.trace_output_dir="/tmp/xdebug"  
    ;指定性能分析文件的存放目录    
    xdebug.profiler_output_dir="/tmp/xdebug"  
    xdebug.profiler_output_name="cachegrind.out.%p"  
    ;是否开启远程调试,boolean
    xdebug.remote_enable=1
    ;开启后,将不再使用特定的HTTP GET / POST变量来启动远程调试
    ;Normally you need to use a specific HTTP GET/POST variable to start remote debugging (see Step Debugging). When this setting is set to 1, Xdebug will always attempt to start a remote debugging session and try to connect to a client, even if the GET/POST/COOKIE variable was not present.
    ; xdebug.remote_autostart=1
    ;Can only be 'dbgp' to represent the debugger protocol. The DBGp protocol is the only supported protocol.
    xdebug.remote_handler=dbgp  
    ; xdebug.remote_host=localhost
    ; xdebug.remote_host='192.168.110.100'
    xdebug.remote_host='192.168.110.1'
    ; xdebug.remote_host=vmv3nfapi.saas.com
    ; xdebug.remote_host=vmdemo.com
    xdebug.remote_port=9000
    ;指定传递给DBGp调试器处理程序的IDE Key
    xdebug.idekey="PHPSTORM"
    xdebug.remote_log="/tmp/xdebug.log"

     

  • 相关阅读:
    数据结构总结——线段树
    [bzoj2131]免费的馅饼 树状数组优化dp
    [机房练习赛7.26] YYR字符串
    博客已搬家
    AFO
    COGS-2551 新型武器
    UVALive-3716 DNA Regions
    UVALive-4850 Installations
    UVALive-3983 Robotruck
    UVA-10859 Placing Lampposts
  • 原文地址:https://www.cnblogs.com/wanghaokun/p/12301456.html
Copyright © 2011-2022 走看看