I’m trying to configure my Symfony 5 application to be run in a read-only system.
But despite configuring it to use Memcached instead of the filesystem for the cached data that is usually written in the application
(according to the documentation, all I need to do is to change the cache adapter for the
system cache pool and for the
app cache pool if desired), I find that Symfony continues writing to
What am I missing? How can I deploy the application in a read only system?
If you configure the system not to use a filesystem based cache, you only need to run
php bin/console cache:warmup, on deployment and then deploy all the generated code (including the contents of
var/cache) to the execution environment.
In the prod environment (i.e. when APP_ENV is prod and APP_DEBUG is 0), as long as you run php bin/console cache:warmup, no cache files will need to be written to disk at runtime. The only exception is when using a filesystem-based cache, such as Doctrine’s query result cache or Symfony’s cache with a filesystem provider configured.
You’ll also need to make sure that you are not logging to disk.
Nowadays, since Symfony 4,
var/cache is mostly meant to store long term artefacts like compiled container files, compiled translations, and/or Doctrine proxies. Not for temporary cache files.
Following these practices, a well configured application should be able to be deployed on read-only environments.