Phe*_*hen 9 php debugging symfony1
我正在使用symfony 1.4和Doctrine.
我正试图找到一种方法来启用调试模式,只有当前sfUser有一个特殊的debugger凭证.
我已经创建了一个过滤器,如果sfUser没有此凭据(在我的文件中web_debug设置为),则停用symfony调试栏:truesettings.yml
class checkWebDebugFilter extends sfFilter
{
public function execute($filterChain)
{
if(!$this->getContext()->getUser()->hasCredential('debugger'))
{
sfConfig::set('sf_web_debug', false);
}
$filterChain->execute();
}
}
Run Code Online (Sandbox Code Playgroud)
我的index.php文件的代码是:
require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod', false));
sfContext::createInstance($configuration)->dispatch();
Run Code Online (Sandbox Code Playgroud)
问题是,由于debug模式false在我的硬编码中index.php,它也被调试器禁用; 因此,Web调试栏不显示Doctrine语句或时序指示.
有没有办法只在当前sfUser具有精确凭证的情况下启用调试模式?
我试图添加sfConfig::set('sf_debug', true);到我的checkWebDebugFilter::execute()方法,但由于过滤器在 Doctrine语句之后执行,因此不会记录它们.
我还尝试添加session_start();我的index.php文件,然后浏览$_SESSION变量以检查当前用户是否具有debugger凭证,但它不起作用(并且它也不符合symfony的精神).
提前感谢您的回答.
小智 -1
尝试这个
如果你想启用 web_debug 面板(开发)模式,那么
http://host_url/frontend_dev.php
或者
在你的index.php中写入'frontend','dev',true。
require_once(dirname( FILE ).'/../config/ProjectConfiguration.class.php'); $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', true)); sfContext::createInstance($configuration)->dispatch();