laradock+phpstorm 开启 xdebug

最近在学L05的电商教程,前面基本都不需要debug,看到支付宝回调这边,遇到点问题,想看一下回调中返回的串解析出来的数据。之前一直没配置debugg,记录一下怎么开启。

  1. 编辑laradock的.env文件
    查找:WORKSPACE_INSTALL_XDEBUG
    将原本的值false改为true
    查找:PHP_FPM_INSTALL_XDEBUG
    将原本的值false改为true

  2. 编辑workspace和php-fpm的xdebug.ini文件
    这边直接贴一下我的配置
    workspace的xdebug.ini

    xdebug.remote_host=host.docker.internal
    xdebug.remote_connect_back=0
    xdebug.remote_port=9000
    xdebug.idekey=PHPSTORM
    xdebug.remote_autostart=0
    xdebug.remote_enable=1
    xdebug.cli_color=0
    xdebug.profiler_enable=0
    xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.var_display_max_children=-1
    xdebug.var_display_max_data=-1
    xdebug.var_display_max_depth=-1

    php-fpm的xdebug.ini

    xdebug.remote_host=host.docker.internal
    xdebug.remote_connect_back=0
    xdebug.remote_port=9000
    xdebug.idekey=PHPSTORM
    xdebug.remote_autostart=0
    xdebug.remote_enable=1
    xdebug.cli_color=0
    xdebug.profiler_enable=0
    xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.var_display_max_children=-1
    xdebug.var_display_max_data=-1
    xdebug.var_display_max_depth=-1
  3. 重新laradock的workspace和php-fpm的镜像
    docker-compose build workspace php-fpm
    build完之后需要重启laradock。
    4.配置PHPSTORM
    添加server
    laradock+phpstorm开启xdebug
    配置DBGp Proxy
    laradock+phpstorm开启xdebug
    点击debug页签中的validate,配置一下你的项目,然后按窗口右下角的validate,如图为验证通过的界面,如果验证不通过的话,会有相应的提示。这个validata也可以在配置监听那边验证。
    laradock+phpstorm开启xdebug
    点击phpstorm右上角的的图中的这个选项,进入配置页面
    laradock+phpstorm开启xdebug
    laradock+phpstorm开启xdebug
    添加完之后点击确定。

  4. 查看调试效果
    用curl方式进行请求
    laradock+phpstorm开启xdebug
    调试界面
    laradock+phpstorm开启xdebug

  5. 关于开启与关闭xdebug
    在laradock的根目录可以进行xdebug的开关
    命令分别为:
    开启php-fpm/xdebug start

laradock+phpstorm开启xdebug

关闭php-fpm/xdebug stop

laradock+phpstorm开启xdebug
建议需要使用debug的时候才开启,因为开启debug,请求的时间相差很大。
同一界面,开启debug与不开启请求时间的差别。
开启:
laradock+phpstorm开启xdebug
关闭:
laradock+phpstorm开启xdebug

本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!