【问题标题】:CakePHP 1.3 DebugKit - setting debug level for specific userCakePHP 1.3 DebugKit - 为特定用户设置调试级别
【发布时间】:2012-04-04 09:04:37
【问题描述】:

我想将特定用户的调试级别设置为 2。如果我使用 app_controller.php 使 DebugKit 不显示,只有我在 core.php 中设置它但我只想这样做一个特定的登录用户。

最好的方法是什么?


更新: 这是我在 app_controller.php 中的 beforeFilter 函数中所做的(没有用):

if($this->Auth->user('id') == 1)
        Configure::write('debug', 2);

【问题讨论】:

    标签: cakephp cakephp-1.3


    【解决方案1】:

    你是怎么做到的?

    通常我在beforeFilter 中在AppController 中执行此操作,并且工作正常。

    if (...) {
        Configure::write('debug', 2);
    }
    

    更新

    function beforeFilter() {
        if ($this->Auth->user('id') == 1) {
            Configure::write('debug', 2);
            $this->components[] = 'DebugKit.Toolbar';
        }
    }
    

    【讨论】:

    • 这就是我所做的,它适用于正常的 CakePHP 调试,但只有当我更改 core.php 中的值时,DebugKit 才会出现(但我不希望所有用户都能看到这个)。
    • 好的!由于DebugKit是一个组件,你可以根据需要尝试附加和分离。检查我的更新。
    • 啊,我明白了。但在这种情况下,我必须在 core.php 中将 debug 设置为 2,每个人都会看到它。有没有办法只为特定用户在 bootstrap.php 中设置调试?
    • 我不明白为什么需要在 core.php 中将 debug 设置为 2。既然你说在 app_controller.php 中定义它是有效的,那么不能在beforeFilter 中设置调试级别和附加组件?
    • 哦,对不起,这就是我的意思:如果我想要标准的 CakePHP 调试,在 app_controller.php 中将其设置为 2 即可。但我想使用 DebugKit。在 app_controller.php 中将 debug 设置为 2 不会使 DebugKit 出现。如果我在 core.php 中设置它,DebugKit 确实会出现(这就是为什么我认为这就是它不起作用的原因)。
    猜你喜欢
    • 1970-01-01
    • 2011-10-04
    • 1970-01-01
    • 1970-01-01
    • 2016-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多