5
votes

With a Composer-based TYPO3 installation, when is it necessary to flush caches, and how to do it?

With the extension manager, the flushing of caches happens automatically when an extension is installed or updated.

Is it recommended to do a (hard) cache flush in some cases, e.g.

  • extension installation
  • extension update
  • extension removal

Also, what is the equivalent of doing a flush cache operation in Maintenance mode ("Install Tool") from the command line?

2
Your question is not fully clear, are you talking about a dev environment? Then check also our additional packages github.com/TYPO3-Console/composer-auto-commands and maybe github.com/TYPO3-Console/composer-typo3-auto-install. On a production server cache flushing is normally done during the deployment and not really related to Composer.Simon Gilli
@Simon Thanks for the advice - I updated the question. I meant in production on a Composer based setup.Sybille Peters
I plan on using deployer but assume the use of deployment tool shouldn't really be the issue here.Sybille Peters
@Simon From reading the description github.com/TYPO3-Console/composer-typo3-auto-install I don't understand what it does and what it has to do with cache flushing. I have already installed helhum/typo3_console, helhum/dotenv-connector, gordalina/cachetool. Not sure if or why I need these other tools.Sybille Peters
Cache flushing is done with composer-auto-commands but only on dev environments. So if you call composer with --no-dev this part is not executed. Check github.com/TYPO3-Console/composer-auto-commands/blob/master/src/… for more information. You could include this commands also as scripts like suggested below.Simon Gilli

2 Answers

1
votes

Have a look at this extension: https://packagist.org/packages/helhum/typo3-console it allows you to execute commands on your typo3 installations programmatically including one called cache:flush

You can then utilize composer hooks like post-autoload-dump to execute this command. So it might look something like this in your composer.json:

"scripts": {
  "post-autoload-dump": [
    "typo3cms install:generatepackagestates",
    "typo3cms install:fixfolderstructure",
    "typo3cms install:extensionsetupifpossible"
    "typo3cms cache:flush"
  ]
}

I can't tell you if it's recommended though as I don't run composer on my production server.

1
votes

If you add the extensions through composer, but still install (enable) them in the TYPO3 Extension Manager or using typo3_console, the cache will still be automatically flushed. For updated extensions, or if you install the extensions directly in PackageStates.php (through git for example) it is recommended to flush the cache and do a database compare (or extension setup).

As crs says in his answer, you can flush the cache with the typo3_console extension. You can even specify which caches you want to flush using cache:flushcache. You can also do a database compare with that extension from the command line using database:updateschema or extension setup using extension:setupactive (which does the database changes and default configuration for active extensions)