简体   繁体   中英

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.

You can get the variables defined in current scope using get_defined_vars() method and log it using Monolog library eg

    $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. For more info about logging checkout this cookbook entry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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