Symfony2:具有多个环境的相同代码库会导致大量缓存文件

I have a running Symfony2 application which uses the same codebase, but different environment names to map to different DBs.

For example:

foo.example.com --> uses env foo bar.example.com --> uses env bar

Of course, I have now different cache and logs for each user.

The cache thing is what bothers me, it's creating tons of files (1 cache dir per subdomain), and it ended up filling my inodes to the limit.

Is there a way to share the cache between environments, or maybe not using environments to access different dbs?

Each subdomain should have its own DB, that's the only requirements. Right now we are using different environments to accomplish that.

Suggestions?

The problem is not that an environment has a lot of cache files. The problem is that the idea of environment is exploited the wrong way.

A better solution for your situation is to define your db name based on the subdomain: foo.example.com will have the db foo_db, etc. A simple convention like that.

This answer may help you

https://stackoverflow.com/a/8314039/410761

You override the base methods to define whatever cache / logs folder you prefer.