Symfony: Showing the dev toolbar in “prod” environment

给你一囗甜甜゛ 提交于 2019-12-11 05:37:31

问题


I managed to interactively set the debugging mode of my symfony application On and Off for a user session with something like this:

$configuration = ProjectConfiguration::getApplicationConfiguration($app,
                                                           $env, $debugging);

I know that the Web Debug Toolbar showing up or not does not depend on the value of $debugging, but the configuration of the current environment.

To this moment the only way that the toolbar appears is when $env = 'dev'.

I'd like to activate it when accessing the "prod" environment also.

I have this app setting:

prod:
  .settings:
    no_script_name:         true
    logging_enabled:        false
    web_debug:              true
    error_reporting:        <?php echo (E_ALL | E_STRICT)."\n" ?>

dev:
  .settings:
    error_reporting:        <?php echo (E_ALL | E_STRICT)."\n" ?>
    web_debug:              true
    cache:                  false
    no_script_name:         false
    etag:                   false

The toolbar is not being shown, apparently ignoring the "web_debug" setting.

If I echo(sfConfig::get('sf_web_debug')) I get "true".

¿How could I get the toolbar working?


回答1:


you also need to change the factory.yml . By default, there's no Logger in the 'prod'-environment.

Just comment out like this:

prod:
#  logger:
#    class:   sfNoLogger
#    param:
#      level:   err
#      loggers: ~



回答2:


From memory you have to change a value in your frontend php file. Compare the frontend.php and frontend_dev.php files in your web directory. Look for a difference where one is true and the other is false (I think it's the last parameter).

The lines are:

require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false));
sfContext::createInstance($configuration)->dispatch();

change to:

require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', true));
sfContext::createInstance($configuration)->dispatch();


来源:https://stackoverflow.com/questions/7198375/symfony-showing-the-dev-toolbar-in-prod-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!