简体   繁体   English

Symfony2:调试控制器变量

[英]Symfony2: debug controller variables

How can I quickly acces and view variables that are used in the controller ? 如何快速访问和查看控制器中使用的变量? I use xdebug, but often it is overkill to see what is inside an object when passing trough the controller. 我使用xdebug,但通常在通过控制器时看到对象内部是什么太过分了。

You can get the variables defined in current scope using get_defined_vars() method and log it using Monolog library eg 您可以使用get_defined_vars()方法获取当前范围中定义的变量,并使用Monolog库进行记录,例如

    $this->container->get('logger')->info('Local variables', get_defined_vars());

I would recommend installing FirePHP extension in Firefox because in dev mode FirePHP handler is automatically enabled so you can see the info messages in firebug console. 我建议在Firefox中安装FirePHP扩展,因为在开发模式下, FirePHP处理程序会自动启用,因此您可以在firebug控制台中查看信息消息。 For more info about logging checkout this cookbook entry. 有关记录结帐烹饪书条目的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM