Ask your Symfony questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Best way to turn off cache, including the need for cache folder? Symfony


I want to delete the cache folder from the Symfony project I'm working on. I do not want to deal with the cache at all, nor do I want Symfony throwing an error because it can not find the folder. (I'll be using other systems for caching).

I can turn off cache in settings.yml, but Symfony still looks for the cache folder. What do I do to stop it from even looking for the folder?

(Why? I'm trying to share one code installation with 100 sites, and the centralized cache shares templates between the different sites.)

Version 1.2.5

Answers (4)


Jakub Zalas answers:

It's not the best idea. Some things just have to be cached (like configurations, autoloading etc).

I would really use ysfDimensionsPlugin in this case. It would add additional subdirectories for each of your users in cache folder.

Lawrence Krubner comments:

That does look intriguing, Jakub. Thanks.


Ivan Rey answers:

Jakub is right. It's not a good idea specially since you don't want to be parsing configurations and routing on every single request.

However most of your problems can be resolved overriding sfProjectConfiguration and sfApplicationConfiguration methods. Both clases have methods that return the paths to the templates, configuration, cache, etc. You could override them and use whatever logic comes handy to have different caches for each of your sites. You could even have a completely different cache folder for each site that way they don't get into each other business and you could even have specialized configurations for each one.

look at the setCacheDir in sfApplicationConfiguration and in sfProjectConfiguration.


Nate Flink answers:

You might want to look into using the junk from symfony 2 which seems like it was designed for more of an ale carte style of coding. Idea here being, whether it's symfony 1.4 or symfony 2, to utilize symfony platform code, decoupled from the framework code, to accomplish the goals of your app.

I've been following questions you've posted about this project, and I get the idea that your doing some seriously heavy duty hacking of things in the symfony project. At some point, you've gotta ask yourself, does it really make sense to be using a framework for this? Symfony lends itself well for lots of different things, but it's not going to be the right solution for 100% of the cases and there are lots of other technologies out there.

For example, you might want to look at something like CouchDB. That would totally simplify your whole deal, imho.

I'm not qualified to write intelligently about Couchdb, but the basic idea as I understand it is that your eliminated the entire application layer from client-application server-database server model, and you end up with flexible simpler code.

There are lots of options. I don't wanna tell you your business, but taking a step back to assess options will usually pay for itself later.


Loban Rahman answers:

Lawrence, I agree to a large extent with what everyone has said so far.

I, too, have been following the questions for your project, and I've been feeling that with all your heavy-duty "over-riding" of core symfony stuff, you are perhaps over-complicating things.

Maybe you should reconsider your approach: It seems you are attempting to run 100 sites all through one application in symfony. Hence all the sites are sharing the same cache folder. Why not put each "site" in a separate "application" (each of which has its own folder in cache).

Lawrence Krubner comments:

That certainly might be true. My thought here is that if we can simply get something working, then it can function as a proto-type for the kind of service that we'd like to build. So long as we have something working that we can point people to, then we've all of 2011 to think about what the true architecture should be.