I've created a deployment script for my Symfony applications that fetches updates from a git-repo. It downloads dependencies, updates schema, installs assets, then clears and warms up the cache
It works well (as far I know?) but I need a way to get/store the last time the cache was cleared. Preferably I don't want to write to a file or update a record in a database from the shell, I rather detect/fetch the the last time it was cleared and rebuilt inside my Symfony application.
Is there any way to do this? I thought of getting the created time of the prod cache folder..
Here's the script I wrote: https://github.com/StrikeForceZero/DeploySymfony/blob/master/DeploySymfony.sh
One way to do this would be to write to the Symfony logs using Symfony's built in logging service Monolog (http://symfony.com/doc/current/cookbook/logging/monolog.html). You can either create a Symfony console command (http://symfony.com/components/Console) that your script executes to write to the logs, or you can use inheritance to override one of the Symfony methods that you want to log, that simply calls the logger service, updates the log, and calls its parent method.
For example, instead of calling 'app/console cache:clear' you can call your child method that inherits from CacheClearCommand, update the configure method to set a new name for your command, override the execute method to call your log (either before or after the child executes its parent) and that should be about it. In your deployment script call your custom cache:clear command instead of Symfony's.