filament:clear-cached-components — Filamentのキャッシュをクリアするコマンド
artisan
2026.03.10
filament:clear-cached-components
概要
Filament の管理パネルでは Livewire コンポーネントを多数キャッシュし、起動時のパフォーマンスを向上させます。
filament:clear-cached-components は 既存のコンポーネントキャッシュ(Blade と Livewire コンポーネント) をすべて削除し、再キャッシュを作成できるようにします。
キャッシュを更新したあとに実行すると、UI の変更を即座に反映できます。
カテゴリー
タイプ
パッケージ
関連 API
artisan
コマンド
filamentphp/filament
filament:cache-components, icons:cache, filament:cache-icons
コマンド構文
php artisan filament:clear-cached-components
パラメータ
引数・オプション
必須
デフォルト
説明
なし
〇
—
引数はありません。
※ Filament のキャッシュは「コンポーネント」「アイコン」の 2 種類があるため、両方を同時に削除 します。
戻り値
型
説明
int
コマンド実行時のステータスコード(0 が成功)
Laravel の Command クラスは int を返すため、テスト時は assertSuccessful() を利用できます。
例外
例外クラス
発生し得る状況
Symfony\Component\Console\Exception\CommandNotFoundException
Filament パッケージがインストールされていない、またはバージョンが古い
RuntimeException
ファイルシステムに書き込み権限がない
最小構成例
php artisan filament:clear-cached-components
PHP での実行例(Artisan テスト)
<?php
use Illuminate\Support\Facades\Artisan;
Artisan::call('filament:clear-cached-components');
$this->assertEquals(0, Artisan::output());
実務例
# 開発環境:UI コンポーネントを更新した後
php artisan filament:clear-cached-components
# 再キャッシュ作成
php artisan filament:cache-components
php artisan icons:cache
更新後にキャッシュをクリアし再生成すると、ブラウザキャッシュの不整合を防げます。
よくある落とし穴
落とし穴
原因
対処
コマンドが未定義
古い Filament (<3.0) で存在しない
Filament をアップデート
権限不足
storage・bootstrap の書き込み権限が低い
chmod -R 775 storage bootstrap もしくは chown -R www-data:www-data
キャッシュが残る
icons:cache のキャッシュが別に残る
php artisan icons:clear-cache も併せて実行
代替手段
代替
説明
手動削除
rm -rf bootstrap/cache/filament* storage/framework/views/*.php
UI ボタン
Filament の管理画面に「キャッシュクリア」ボタンを追加するパッケージを導入(例:cms-multi/filament-clear-cache)
テスト例(Pest)
<?php
use Illuminate\Support\Facades\Artisan;
it('clears cached components successfully', function () {
Artisan::call('filament:clear-cached-components');
expect(Artisan::output())->toContain('All cached Filament components have been cleared.');
});
トラブルシューティング
症状
原因
対処
Command "filament:clear-cached-components" is not defined.
Filament がインストールされていない
composer require filamentphp/filament
書き込み不可
storage/bootstrap のパーミッションが低い
chmod -R 775 storage bootstrap
キャッシュが残る
icons:cache のキャッシュが残っている
php artisan icons:clear-cache も実行
参考文献
Filament Docs: Caching Filament components – https://filamentphp.com/docs/4.x/deployment
Commands.app: Filament Admin Panel commands – https://commands.app/filament
GitHub Discussions: Delete Resource · filamentphp filament – https://github.com/filamentphp/filament/discussions/1864