【问题标题】:Symfony cache default folder pathSymfony 缓存默认文件夹路径
【发布时间】:2012-01-03 15:12:31
【问题描述】:

Symfony2 将缓存保存在 app\cache 文件夹中

有没有办法将其更改为不同的路径?

感谢您的帮助!

答案:

感谢 Aurelijus Valeiša 的贡献!

我确实添加了这样的方法(到 AppKernel.php):

public function getCacheDir()
{
    // Remove whole method if you want to go back to the original cache folder
    return 'c:/Users/Mike/Documents/www/cache/'.$this->environment;
}  

如果您想对日志文件夹执行相同操作,请添加此方法:

public function getLogDir()
{
    // Remove whole method if you want to go back to the original log folder
    return 'c:/Users/Mike/Documents/www/logs';
}

请注意,这两种方法都只是覆盖在 Symfony\Component\HttpKernel\Kernel 类中创建的原始方法

【问题讨论】:

    标签: php symfony


    【解决方案1】:

    是的,在app/AppKernel.php 文件中覆盖getCacheDir() 方法(在Symfony\Component\HttpKernel\Kernel 中定义)。 例如,在您的扩展 AppKernel 类中,您可以:

    public function getCacheDir()
    {
        return $this->rootDir.'/superduper_cache/'.$this->environment;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-26
      • 1970-01-01
      • 2019-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多