使用Symfony2更改cache_dir和log_dir [英] Changing cache_dir and log_dir with Symfony2

查看:430
本文介绍了使用Symfony2更改cache_dir和log_dir的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于部署限制,我希望我的Symfony2应用程序使用的日志和缓存目录在/ var / ...在我的文件系统中。因此,我正在寻找一种方法来配置Symfony并覆盖这两个目录的默认位置。

Because of deployment constraints, I would like to have the log and cache directories used by my Symfony2 application somewhere under /var/... in my file system. For this reason, I am looking for a way to configure Symfony and to override the default location for these two directories.

我看到了kernel.cache_dir和kernel.log_dir并读取类Kernel.php。从我所看到的,我不认为可以通过配置更改dir位置,我将补丁Kernel.php类。

I have seen the kernel.cache_dir and kernel.log_dir and read the class Kernel.php. From what I have seen, I don't think that it is possible to change the dir locations by configuration and I would have to patch the Kernel.php class.

推荐答案

将以下方法添加到应用程序中/AppKernel.php(AppKernel extends Kernel)让它们返回你喜欢的路径:

Add the following methods to app/AppKernel.php (AppKernel extends Kernel) making them return your preferred paths:

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

public function getLogDir()
{
    return $this->rootDir . '/my_logs';
}

这篇关于使用Symfony2更改cache_dir和log_dir的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆