問題描述
有沒有辦法禁用Symfony2中的緩存功能?我試圖在 config* 和 parameters.ini 文件中找到設置,并進行了大量搜索.好的,我找到了一些解決方案,但對于最新版本 (Symfony2) 沒有任何解決方案.
Is there a way to disable the caching function in Symfony2? I tried to find the setting in the config* and parameters.ini files and I searched a lot. Ok, I found a few solutions, but nothing for the latest version (Symfony2).
為什么?因為我想在不清除應用程序/緩存* 的情況下測試新模板和功能.
WHY? Because I want to test new templates and functions without clearing the app/cache* all the time.
推薦答案
我假設您正在使用 Twig 引擎(Symfony2 的默認模板引擎).在 Twig 中禁用緩存,這樣您就不必像這樣繼續清除緩存:
I'm assuming you're using the Twig engine, (the default templating engine for Symfony2). To disable caching in twig, so that you do not have to keep clearing the cache like so:
rm -rf app/cache/*
導航到您的應用配置文件(默認情況下將位于根目錄中的 ../app/config/config.yml).滾動到 twig 配置設置(在 twig: 下)并將緩存值(應該指向緩存目錄)更改為 false,如下所示:
Navigate to your app config file (by defualt will be located in ../app/config/config.yml from your root directory). Scroll to the twig configuration settings (under twig:) and change the cache value (which should be pointing to the cache directory) to false like so:
twig:
cache: false
如果您沒有看到任何緩存配置條目,只需添加上面的行.
查看 Twig 包的配置參考也可能會有所幫助:http://symfony.com/doc/2.0/reference/configuration/twig.html
It may also be helpful to checkout the configuring reference for the Twig bundle: http://symfony.com/doc/2.0/reference/configuration/twig.html
編輯 config_dev.yml 文件后,轉到終端并運行:
After editing your config_dev.yml file, go to your terminal and run:
app/console cache:clear
這篇關于Symfony2 禁用緩存?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!