有没有办法禁用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 禁用缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!