Symfony缓存默认文件夹路径

时间:2012-01-03 15:12:31

标签: php symfony

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

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

感谢您的帮助!

答案:

感谢AurelijusValeiš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类中创建的原始

1 个答案:

答案 0 :(得分:5)

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

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