Symfony2 disable cache?
Is there a way to disable the cac开发者_Go百科hing 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.
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/*
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
If you do not see any cache configuration entry, simply add the line above.
It may also be helpful to checkout the configuring reference for the Twig bundle: http://symfony.com/doc/2.0/reference/configuration/twig.html
After editing your config_dev.yml file, go to your terminal and run:
app/console cache:clear
Okay, regarding your clarification the solution simply is to use the dev-environment through the front-controller web/app_dev.php. Then sf2 keeps track of your adjustments and you don't have to clear the cache.
This original solution works for me http://symfony.com/doc/current/cookbook/debugging.html
In addition to the accepted answer, I propose to edit your config_dev.yml in a way so it still debugs your twig template. To do so, add this code to your config_dev.yml file:
twig:
cache: false
debug: true
services:
twig.extension.debug:
class: Twig_Extension_Debug
tags:
- { name: 'twig.extension' }
After editing your config_dev.yml file, go to your terminal and run:
app/console cache:clear
By doing so, you will reload your config_dev.yml settings - make your project run with the new configuration.
Hope this helps.
Edit 'config_dev.yml' and 'config.yml' and then put in both
twig:
cache: false
精彩评论