2012-01-03 161 views
2

Symfony2将缓存保存在app \ cache文件夹中Symfony缓存默认文件夹路径

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

感谢您的帮助!

答:

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

回答

4

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

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