如何在CLI上使XDebug与PHPUnit一起运行?

编程入门 行业动态 更新时间:2024-10-11 19:22:03
本文介绍了如何在CLI上使XDebug与PHPUnit一起运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试运行以下CLI命令:

I've tried running the following CLI command:

phpunit -d xdebug.profiler_enable=on XYZTestCase.php

但是它只是正常运行.谁能指出我正确的方向?谢谢!

but it just runs as normal. Can anyone point me in the right direction?? Thx!

这是XDebug设置:

Here's the XDebug settings:

xdebug xdebug support => enabled Version => 2.1.2 Supported protocols => Revision DBGp - Common DeBuGger Protocol => $Revision: 1.145 $ Directive => Local Value => Master Value xdebug.auto_trace => Off => Off 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.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.idekey => Nam => no value xdebug.manual_url => www.php => www.php xdebug.max_nesting_level => 100 => 100 xdebug.overload_var_dump => On => On xdebug.profiler_aggregate => Off => Off xdebug.profiler_append => Off => Off xdebug.profiler_enable => Off => Off xdebug.profiler_enable_trigger => Off => Off xdebug.profiler_output_dir => c:/wamp/tmp => c:/wamp/tmp xdebug.profiler_output_name => cachegrind.out.%t.%p => cachegrind.out.%t.%p xdebug.remote_autostart => On => On 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 => localhost => localhost xdebug.remote_log => no value => no value xdebug.remote_mode => req => req xdebug.remote_port => 9000 => 9000 xdebug.scream => Off => Off xdebug.show_exception_trace => Off => Off xdebug.show_local_vars => Off => Off xdebug.show_mem_delta => Off => Off xdebug.trace_format => 0 => 0 xdebug.trace_options => 0 => 0 xdebug.trace_output_dir => \ => \ 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

推荐答案

xdebug.profiler_enable设置不能在运行时更改,而只能在脚本开始时更改.

The xdebug.profiler_enable setting can't be changed at runtime but only at the start of script.

运行phpunit -d foo=bar只会导致phpunit调用ini_set("foo", "bar");,这是行不通的,因为该值在运行时无法更改.

Running phpunit -d foo=bar will just lead to phpunit calling ini_set("foo", "bar"); and that doesn't work since the value can't change at runtime.

请参阅:> xdebug.profiler_enable

启用Xdebug的探查器,该探查器在探查器输出目录中创建文件. KCacheGrind可以读取这些文件以可视化您的数据.无法使用ini_set()在脚本中设置此设置.如果要有选择地启用探查器,请将xdebug.profiler_enable_trigger设置为1,而不要使用此设置.

Enables Xdebug's profiler which creates files in the profile output directory. Those files can be read by KCacheGrind to visualize your data. This setting can not be set in your script with ini_set(). If you want to selectively enable the profiler, please set xdebug.profiler_enable_trigger to 1 instead of using this setting.

解决方案:

php -d xdebug.profiler_enable=on /usr/bin/phpunit XYZTestCase.php

通过直接将设置应用到PHP运行时而不是phpunit,将在脚本启动前设置并且可以正常工作.

By applying the setting directly to the PHP runtime and not phpunit it will be set before the script starts and should work.

更多推荐

如何在CLI上使XDebug与PHPUnit一起运行?

本文发布于:2023-11-14 04:02:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586160.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   CLI   PHPUnit   XDebug

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!