Changing cache_dir and log_dir with Symfony2

前端 未结 7 2005
感动是毒
感动是毒 2021-02-19 13:50

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

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-19 14:20

    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.

提交回复
热议问题