Symfony缓存默认文件夹路径

Tro*_*ike 3 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;
}  
Run Code Online (Sandbox Code Playgroud)

如果要对logs文件夹执行相同操作,请添加以下方法:

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

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

aur*_*usv 5

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

public function getCacheDir()
{
    return $this->rootDir.'/superduper_cache/'.$this->environment;
}
Run Code Online (Sandbox Code Playgroud)