Symfony 缓存默认文件夹路径 [英] Symfony cache default folder path
问题描述
Symfony2 将缓存保存在 app\cache 文件夹中
Symfony2 keeps cache in app\cache folder
有没有办法把它改成不同的路径?
Is there a way to change it to different path?
感谢您的帮助!
答案:
感谢 Aurelijus Valeiša!
Thanks to Aurelijus Valeiša for this!
我确实添加了这样的方法(到 AppKernel.php):
I did add method (to AppKernel.php) like this:
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;
}
如果您想对日志文件夹执行相同操作,请添加此方法:
If you want to do the same with logs folder add this method:
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 类中创建的原始方法
Make a note that both methods just overwrite original which are created in Symfony\Component\HttpKernel\Kernel class
推荐答案
是的,在 app/AppKernel.php
文件中重写 getCacheDir()
方法(定义在 Symfony\Component\HttpKernel\Kernel
).例如,在扩展的 AppKernel
类中,您可以拥有:
Yes, in app/AppKernel.php
file override getCacheDir()
method (defined in Symfony\Component\HttpKernel\Kernel
).
As the example, in your extended AppKernel
class you could have:
public function getCacheDir()
{
return $this->rootDir.'/superduper_cache/'.$this->environment;
}
这篇关于Symfony 缓存默认文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!