cms-multi/filament-clear-cache
Adds a “Clear Cache” button to your Filament admin toolbar so you can quickly run cache-clearing commands without leaving the panel. Supports Filament v2–v5 (via plugin versions) and configurable via a publishable config.
composer require cms-multi/filament-clear-cache
app/Providers/Filament/AdminPanelProvider.php):
use CmsMulti\FilamentClearCache\FilamentClearCachePlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
FilamentClearCachePlugin::make(),
]);
}
optimize:clear and refreshes the page.Default Behavior:
php artisan optimize:clear when clicked.Conditional Activation:
local, staging):
FilamentClearCachePlugin::make()
->enabled(app()->environment(['local', 'staging']))
Custom Commands:
use CmsMulti\FilamentClearCache\Facades\FilamentClearCache;
FilamentClearCache::addCommand('page-cache:clear');
boot() method.Livewire Integration:
// Livewire v3+
$this->dispatch('clearCacheIncrement')->to(\CmsMulti\FilamentClearCache\Http\Livewire\ClearCache::class);
Translation Support:
filament-clear-cache::clear-cache).laravel-debugbar to monitor cache impact.enabled()).Performance Impact:
enabled() to restrict access.php artisan optimize:clear --no-interaction in scripts or CI/CD pipelines.Livewire Caching:
return redirect()->back()->with('success', 'Cache cleared!');
Command Conflicts:
route-cache:clear --tags=admin) may fail silently.Visibility on Simple Pages:
config/filament-clear-cache.php for visible settings.Artisan::call('optimize:clear', ['--verbose' => true]);
$this->dispatch('clearCacheIncrement')->to(\CmsMulti\FilamentClearCache\Http\Livewire\ClearCache::class);
Check browser console for errors (e.g., Uncaught Error: Livewire event not found).Custom Styling:
resources/views/vendor/filament-clear-cache.Pre/Post Actions:
FilamentClearCache::extend(function ($plugin) {
$plugin->beforeClear(function () {
// Pre-clear logic (e.g., log event)
});
});
Multi-Tenancy:
handle() method:
FilamentClearCachePlugin::make()
->handle(function () {
Tenant::current()->clearCache();
});
Published Config: Publish with:
php artisan vendor:publish --provider="CmsMulti\FilamentClearCache\FilamentClearCacheServiceProvider"
Key options:
visible: Toggle button visibility (default: true).commands: Array of custom commands to include.session_key: Customize the session key for cache counts.Session Key: If using changes_count, ensure the session driver is configured (e.g., file, database).
How can I help you explore Laravel packages today?