代码之家  ›  专栏  ›  技术社区  ›  Shardj

Xdebug对所有cli命令都运行,尽管远程自动启动被禁用

  •  3
  • Shardj  · 技术社区  · 6 年前

    如果没有从php.ini中完全禁用Xdebug,我目前无法停止Xdebug对所有cli命令的运行。以前,如果需要通过cli进行调试,我会将remote\u autostart切换为enable。我的问题是特别引起问题的作曲家,有效地使它无法名状。Composer声称,如果他们看到Xdebug正在运行,那么Composer应该在Xdebug不运行的情况下重新启动,这应该是从Composer版本1.3开始修复的,但是我使用的是Composer 1.7.3。

    这是在我的alpine PHP-FPM docker容器中运行的,但这并没有什么区别。这个问题以前也有一个同事在流浪汉里面遇到过,所以如果需要的话,我也可以得到他的环境细节。

    我自己设置的php.ini Xdebug设置:

    zend_extension=/var/www/html/xdebug/modules/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_port=9000
    xdebug.show_local_vars=0
    xdebug.var_display_max_data=10000
    xdebug.var_display_max_depth=20
    xdebug.show_exception_trace=0
    #xdebug.remote_autostart=1
    xdebug.remote_host=172.20.0.1
    xdebug.idekey="PHPSTORM"
    xdebug.remote_log=/srv/www/var/log/xdebug.log
    

    php -i | grep 'xdebug' 输出:

    xdebug
    xdebug support => enabled
    xdebug.auto_trace => Off => Off
    xdebug.cli_color => 0 => 0
    xdebug.collect_assignments => Off => Off
    xdebug.collect_includes => On => On
    xdebug.collect_params => 0 => 0
    xdebug.collect_return => Off => Off
    xdebug.collect_vars => Off => Off
    xdebug.coverage_enable => On => On
    xdebug.default_enable => On => On
    xdebug.dump.COOKIE => no value => no value
    xdebug.dump.ENV => no value => no value
    xdebug.dump.FILES => no value => no value
    xdebug.dump.GET => no value => no value
    xdebug.dump.POST => no value => no value
    xdebug.dump.REQUEST => no value => no value
    xdebug.dump.SERVER => no value => no value
    xdebug.dump.SESSION => no value => no value
    xdebug.dump_globals => On => On
    xdebug.dump_once => On => On
    xdebug.dump_undefined => Off => Off
    xdebug.extended_info => On => On
    xdebug.file_link_format => no value => no value
    xdebug.filename_format => no value => no value
    xdebug.force_display_errors => Off => Off
    xdebug.force_error_reporting => 0 => 0
    xdebug.gc_stats_enable => Off => Off
    xdebug.gc_stats_output_dir => /tmp => /tmp
    xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
    xdebug.halt_level => 0 => 0
    xdebug.idekey => PHPSTORM => PHPSTORM
    xdebug.max_nesting_level => 256 => 256
    xdebug.max_stack_frames => -1 => -1
    xdebug.overload_var_dump => 2 => 2
    xdebug.profiler_aggregate => Off => Off
    xdebug.profiler_append => Off => Off
    xdebug.profiler_enable => Off => Off
    xdebug.profiler_enable_trigger => Off => Off
    xdebug.profiler_enable_trigger_value => no value => no value
    xdebug.profiler_output_dir => /tmp => /tmp
    xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
    xdebug.remote_addr_header => no value => no value
    xdebug.remote_autostart => Off => Off
    xdebug.remote_connect_back => Off => Off
    xdebug.remote_cookie_expire_time => 3600 => 3600
    xdebug.remote_enable => On => On
    xdebug.remote_handler => dbgp => dbgp
    xdebug.remote_host => 172.20.0.1 => 172.20.0.1
    xdebug.remote_log => /srv/www/var/log/xdebug.log => /srv/www/var/log/xdebug.log
    xdebug.remote_mode => req => req
    xdebug.remote_port => 9000 => 9000
    xdebug.remote_timeout => 200 => 200
    xdebug.scream => Off => Off
    xdebug.show_error_trace => Off => Off
    xdebug.show_exception_trace => Off => Off
    xdebug.show_local_vars => Off => Off
    xdebug.show_mem_delta => Off => Off
    xdebug.trace_enable_trigger => Off => Off
    xdebug.trace_enable_trigger_value => no value => no value
    xdebug.trace_format => 0 => 0
    xdebug.trace_options => 0 => 0
    xdebug.trace_output_dir => /tmp => /tmp
    xdebug.trace_output_name => trace.%c => trace.%c
    xdebug.var_display_max_children => 128 => 128
    xdebug.var_display_max_data => 10000 => 10000
    xdebug.var_display_max_depth => 20 => 20
    

    export XDEBUG_CONFIG="idekey=PHPSTORM";
    export PHP_IDE_CONFIG="serverName=docker";
    

    建立cli连接时的Xdebug日志:

    Log opened at 2018-11-08 10:53:30
    I: Connecting to configured address/port: 172.20.0.1:9000.
    I: Connected to client. :-)
    -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/
    xdebug" fileuri="file:///srv/www/pi.php" language="PHP" xdebug:language_version
    ="7.1.23" protocol_version="1.0" appid="863" idekey="PHPSTORM"><engine version=
    "2.6.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><
    url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2
    018 by Derick Rethans]]></copyright></init>
    
    1 回复  |  直到 6 年前
        1
  •  3
  •   Shardj    6 年前

    无证行为

    XDEBUG_CONFIG 环境变量会产生不希望的效果,导致Xdebug在本文底部描述的每个执行上运行。 https://www.larrykagan.com/xdebug-on-docker/

    export XDEBUG_CONFIG="ide=PHPSTORM" 因为那个设置已经在我的ini里了。