Changing cache_dir and log_dir with Symfony2

前端 未结 7 2028
感动是毒
感动是毒 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:38

    I would like to offer an alternative and that is to set environment variables to change these directories. This way it's easier to set depending on the stage. (testing, production or development)

    export SYMFONY__KERNEL__CACHE_DIR "/your/directory/cache"
    export SYMFONY__KERNEL__LOGS_DIR "/your/directory/logs"
    

    Environment variables can also be set in the virtual host with SetEnv. When reading kernel parameters symfony will look for all the $_SERVER variables that start with SYMFONY__, strip the first part and convert all the double underscores into a .

    Source code

    See line 568 to 608

    0 讨论(0)
提交回复
热议问题