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 used the configuration solution from Dragnic but I put the paths in the parameters.yml
file because this file is ignored by git. in other words, it's not synchronized from my PC to the git repository so there is no impact in the prod
environment.
# app/config/parameters.yml
parameters:
database_driver: pdo_mysql
[...]
kernel.cache_dir: "T:/project/cache"
kernel.logs_dir: "T:/project/logs"
Configuration: Windows7, WAMP 2.4 and Symfony 2.3.20.
But you have to know that:
Overwriting the
kernel.cache_dir
parameter from your config file is a very bad idea, and not a supported way to change the cache folder in Symfony.It breaks things because you would now have different cache folders for the kernel
Kernel::getCacheDir()
and for the parameter.
Source: https://github.com/symfony/AsseticBundle/issues/370
So you should use it only in dev
environment and if you don't want to change the content of the app/AppKernel.php file, otherwise see the other answers.