doufu5521 2016-02-10 15:02
浏览 179
已采纳

在Symfony 2中将调试输出打印到浏览器控制台

Could you suggest how to print any debug data into browser console in Symfony 2? Especially, is it possible to implement with Symfony VarDumper Component?
In Zend Framework you can use tool Zend_Log_Writer_Firebug to do so which is very helpful. Does Symfony has something like this from the box?

  • 写回答

1条回答 默认 最新

  • dongzouh51192 2016-02-10 15:36
    关注

    Monolog, the logger used by Symfony, has a built-in support for FirePHP and ChromePHP.

    In Symfony Standard Edition you can configure monolog handlers in your application configuration.

    FirePHP and ChromePHP handlers are even present in config_dev.yml, but are commented out:

    monolog:
        handlers:
            main:
                type: stream
                path: "%kernel.logs_dir%/%kernel.environment%.log"
                level: debug
                channels: [!event]
            console:
                type:   console
                channels: [!event, !doctrine]
            # uncomment to get logging in your browser
            # you may have to allow bigger header sizes in your Web server configuration
            #firephp:
            #    type:   firephp
            #    level:  info
            #chromephp:
            #    type:   chromephp
            #    level:  info
    

    All you need to do to see your logs in the browser is to uncomment the needed handler.

    Currently, the VarDumper component doesn't support dumping anything to the browser's console. However, you can see the dumped values in the web debug toolbar (or in html if you don't use the toolbar).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题