php - XDebug 不会中断来自 atom 的 php-debug 包的断点

标签 php laravel xdebug breakpoints atom-editor

我的问题是我也找到了许多其他答案,但没有一个对我有用。代码和“服务器”都是本地主机。 编辑:尝试使用端口 9001 而不是一些答案中的建议 + 尝试 Visual Studio Code 是否工作,但奇怪的是:它在 VS Code 中中断异常但仍然不在断点处。 连接似乎有效:

enter image description here

我的设置

软件

  • Windows 10 专业版 x64
  • MAMP(非专业版)运行端口 81
  • 原子
  • php调试包
  • xdebug-2.4.1-7.0-vc14.dll 扩展名
  • 要调试的代码写在Laravel框架内

配置

PHP 信息 xdebug 部分

( full )

     xdebug

      xdebug support    enabled
    Version 2.4.1
    IDE Key XDEBUG_ECLIPSE
    XDEBUG NOT LOADED AS ZEND EXTENSION
    Supported protocols Revision
    DBGp - Common DeBuGger Protocol $Revision: 1.145 $
    Directive   Local Value Master Value
    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.force_display_errors Off Off
    xdebug.force_error_reporting    0   0
    xdebug.halt_level   0   0
    xdebug.idekey   no value    no value
    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  C:\Windows\Temp C:\Windows\Temp
    xdebug.profiler_output_name cachegrind.out.%p   cachegrind.out.%p
    xdebug.remote_addr_header   no value    no value
    xdebug.remote_autostart On  On
    xdebug.remote_connect_back  On  On
    xdebug.remote_cookie_expire_time    3600    3600
    xdebug.remote_enable    On  On
    xdebug.remote_handler   dbgp    dbgp
    xdebug.remote_host  127.0.0.1   127.0.0.1
    xdebug.remote_log   no value    no value
    xdebug.remote_mode  req req
    xdebug.remote_port  9000    9000
    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 C:\Windows\Temp C:\Windows\Temp
    xdebug.trace_output_name    trace.%c    trace.%c
    xdebug.var_display_max_children 128 128
    xdebug.var_display_max_data 512 512
    xdebug.var_display_max_depth    3   3

php.ini xdebug 部分

( full )

[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1    # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
xdebug.idekey=xdebug.atom

最佳答案

我已经在此处上传了您的 PHP 信息输出 - https://xdebug.org/wizard.php .除其他外,我收到了下一条消息:“您似乎只将 Xdebug 作为普通 PHP 扩展加载。这会导致奇怪的问题,请参阅 https://xdebug.org/docs/faq#php-ext

Q: Xdebug is only loaded as PHP extension and not as a Zend Extension.

In order for Xdebug to work properly, including breakpoints etc. it is required that it is loaded as a Zend extension, and not just as a normal PHP extension. Some installation tools (PEAR/PECL) sometimes advice you to use extension=xdebug.so to load Xdebug. This is not correct. In order to fix this issue, please look for a line extension=xdebug.so in any of the INI files that are listed under "Loaded Configuration File" and "Additional .ini files parsed" in the top block. Remove this line, and go back to the Tailored Installation Instructions.

下面是针对您的案例的说明:

  1. 下载php_xdebug-2.4.1-7.0-vc14.dll
  2. 将下载的文件移动到C:\MAMP\bin\php\php7.0.9\ext
  3. 编辑 C:\MAMP\conf\php7.0.9\php.ini 并添加行 zend_extension = C:\MAMP\bin\php\php7.0.9\ext\php_xdebug -2.4.1-7.0-vc14.dll
  4. 重启网络服务器

您还可以查看特殊类型的“调试”函数,它带有 xdebug 扩展 - https://xdebug.org/docs/all_functions

例如,您可以使用 xdebug_break()。它允许您在不使用 IDE 的情况下指定断点。


还有一条关于 Atom 设置的说明。本页https://atom.io/packages/php-debug您可能会找到配置过程的说明。我想请您注意 config.cson 文件。在下面查看我的配置片段。你的项目中有类似的东西吗?

"php-debug": 
{
    ServerPort: 9000
    PathMaps: [
        "remotepath;localpath"      
    ]
}

关于php - XDebug 不会中断来自 atom 的 php-debug 包的断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40173485/

相关文章:

javascript - Laravel 未定义

laravel - 在 Laravel Tinker REPL 中导入命名空间

PHP artisan 迁移 :refresh is delete all present data from database

zend-framework - 有没有办法暂时禁用xdebug的var_dump?

php - Laravel 缓存与 Redis 非常慢

php - PHP中如何处理不同的账户类型?

php - 使用 PHP + XDEBUG 时在 VS Code 中显示长字符串

php - xdegug 无法进入 php View 中的下一行

PHP/MySQL。无法更新数据: Query was empty

php - 加载模型的所有关系