What are the files that are cached by default in Symfony - symfony

The below command clears the Symfony cache.
php bin/console cache:clear
My question is what are the files that Symfony caches out of the box.
UPDATED:
I am aware of the default location var/cache where the files are stored. I am looking for a more precise answer.

Related

Symfony 2.8: How do I completely turn off caching?

so we were load testing our server (thus my Symfony page last Friday) and it somehow filled up the app/cache folder.
I've some various discussions on the topic and I modified my config/file
config.yml
twig:
cache: false
app_dev.php (commented out the line below)
//$kernel->loadClassCache();
Is there a way to completely turn off caching? The only workaround I can think of at the moment is to run:
php app/console cache:clear
via cron.
Thanks

Clear Symfony2 Http Cache

Is there an easy way for fast removing http cache in symfony2? We've over 30.000 files in cache directory and removing them tooks very long. Is there an better way for doing this? Btw...linking the cache to /dev/null when removing...
The easiest way to clear cash would be to use console command:
app/console cache:clear
If this is production – you need to add environment (using paramentr --env=prod. )
As default all console commands run in the dev environment.
So, for example, this command looks like app/console cache:clear -e=prod.
Would always recommend using the Symfony console:
php app/console cache:clear --env=prod
This should be fastest, as it moves/renames your current cache folder and creates a new one before deleting your old cache, so there should zero downtime.
If you look in Symfony's cache directory /var/cache/ you'll find an http_cache directory.
So you could use PHP's exec() to remove the directory.
$root = $this->get('kernel')->getRootDir();
$path = $root . '/../var/cache/prod/http_cache';
exec('rm -rf ' . $path);

Variable "app" does not exist with Twig

I'm trying to get the URL of my page with Twig.
So I wrote this in my index.html.twig:
{{ app.request.attributes.get("_route") }}
I'm getting this Symfony exception:
Variable "app" does not in exist in "AcmeFoo..."
I had the same problem and sometimes in addition to clearing the cache, it was necessary to rebuild the bootstrap cache. I created a little shell script (cache.sh) like this:
#!/bin/bash
cd /yoursymfonyrootfolder
php app/console cache:clear --env=prod
#path depends on symfony version
php ./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
Just place that file in your symfony root folder and execute it with ./cache.sh

Symfony2 - confused cache clear trying to write to pro_

My Symfony installation seems to have gotten confused somewhere (probably during a failed cache clear). It seems to think that the production cache folder should be called pro_ instead of prod.
First, when I tried to run $ php console cache:clear --env=prod I got the error message:
[Symfony\Component\Filesystem\Exception\IOException]
Cannot rename "...cache/pro_" to "...cache/pro_".
I'm running on a windows dev machine (so there are no file system permissions issues).
So, I tried deleting all of the cache/* files/folders manually and trying again. This time the cache:clear went through and produced a single prod folder. That folder has subfolders for annotations, assetic, doctrine, sessions and twig.
But when I open the prod front controller (e.g. http://devsite/ in a browser) it fails with the message:
Fatal error: require() [function.require]:
Failed opening required '...cache/pro_/doctrine/orm/Proxies\__CG__AcmeDemoBundleEntityFoo.php'
(include_path='blah, blah, blah')
in ...\vendor\doctrine\common\lib\Doctrine\Common\Proxy\AbstractProxyFactory.php on line 165
From the looks of this it's trying to access cache files in pro_ instead of prod (again).
Looking in the cache folder I can see that __CG__AcmeDemoBundleEntityFoo.php exists under cache\prod but there is now a pro_ folder with annotations and sessions sub-folders.
What's going on and how do I make Symfony forget about pro_ so it can go back to using prod for everything?
I thought everything to do with the cache was stored under the cache folder... is there something else (somewhere) that's storing some reference to pro_? Or am I looking in the wrong place for the solution to this problem?
Edit: Done some more searching and appProdProjectContainer.php contains 16 references to .../cache/pro_. If I manually search and replace these to .../cache/prod the site works. But the next time I run console cache:clear it resets them back to pro_. Where could this errant behaviour be coming from?
Edit2: OK, I got to the bottom of this and have submitted a PR to the Symfony core to try and fix it. The problem was caused by our cache path containing '\' characters which were then escaped in the cache files and failing to match a search/replace command which was meant to clean them up.
app/console cache:clear --env=prod --no-warmup
composer dump-autoload -o
app/console cache:warmup --env=prod
This was a bug in Symfony's handling of cache paths with back-slashes in them.
The short term workaround is to replace them with forward slashes.
Longer term there is a fix posted as https://github.com/symfony/symfony/pull/9184 which will be brought into the core code soon.

Symfony 2.0 assetic dump produces wrong names in debug mode

I'm compressing my javascripts via assetic (block in twig for all scripts in one dir) which works fine in prod mode. Now i want to use the debug mode for my prod env, so i switch assetic to debug in the config, clear the cache and dump the assets with debug on.
This works for some javascripts but not all. Symfony adds a suffix number to them which is higher (by one) on the website (javascript tag) in opposite to the real file. Sometimes clearing the cache and dumping again solved the problem, but noot this time.
For example:
It dumps: /web/js/main_part_3_jquery-ui_6.js
But uses: /web/js/main_part_3_jquery-ui_1.js
So how can i solve this?
Edit:
The wron suffix doesn't appear on the first request to the site after cleaning the cache.
Since app/console assetic:dump is sensible for cached yml files - you should clear the cache for dumping assets each time you change configuration.
Best of all is to do it in this sequence:
rm -rf app/cache/*
app/console assets:install web
app/console assetic:dump
Of course, with debug keys, needed environments and so on
I had a similar problem of multiple generated assets and symfony not including the good one on display.
It was because of busting cache enabled in my case, and it was apparently misconfigured. (apparently it's usefull when you need a new version of your files, for example when you update your .js in dev but don't want to break prod )
So disabling it in config.yml fixed it.
assetic:
workers:
cache_busting:
enabled: false

Resources