craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.21k stars 624 forks source link

Clear cache via console (cache/flush-all) #2099

Closed timkelty closed 6 years ago

timkelty commented 6 years ago

Yii already has console commands to flush the cache:

This is Yii version 2.0.13.

The following commands are available:
- cache                       Allows you to flush cache.
    cache/flush               Flushes given cache components.
    cache/flush-all           Flushes all caches registered in the system.
    cache/flush-schema        Clears DB schema cache for a given connection component.
    cache/index (default)     Lists the caches that can be flushed.

Would be great if we could use the craft console to flush.

Currently, this throws an error, as it seems the @web and @webroot path aliases aren't available:

❯ ./bin/craft cache/flush-all
Exception 'yii\base\InvalidParamException' with message 'Invalid path alias: @webroot/cpresources'

in /Users/timkelty/Sites/coalesse-craft3/vendor/composer/yiisoft/yii2/BaseYii.php:154

Stack trace:
#0 /Users/timkelty/Sites/coalesse-craft3/vendor/composer/yiisoft/yii2/web/AssetManager.php(211): yii\BaseYii::getAlias('@w

Similar/related issue: https://github.com/yiisoft/yii2/issues/12631

timkelty commented 6 years ago

Thanks! 💯