diff --git a/src/Illuminate/Foundation/Console/ConfigCacheCommand.php b/src/Illuminate/Foundation/Console/ConfigCacheCommand.php index cedf0309dabc..bc87648533ad 100644 --- a/src/Illuminate/Foundation/Console/ConfigCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ConfigCacheCommand.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; +use Illuminate\Console\ConfirmableTrait; use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Arr; @@ -13,12 +14,15 @@ #[AsCommand(name: 'config:cache')] class ConfigCacheCommand extends Command { + use ConfirmableTrait; + /** - * The console command name. + * The name and signature of the console command. * * @var string */ - protected $name = 'config:cache'; + protected $signature = 'config:cache + {--force : Force the operation to run when in production}'; /** * The console command description. @@ -55,6 +59,10 @@ public function __construct(Filesystem $files) */ public function handle() { + if (! $this->confirmToProceed()) { + return; + } + $this->callSilent('config:clear'); $config = $this->getFreshConfiguration(); diff --git a/src/Illuminate/Foundation/Console/EventCacheCommand.php b/src/Illuminate/Foundation/Console/EventCacheCommand.php index 4b6edf67d8ad..0718d1d74ddb 100644 --- a/src/Illuminate/Foundation/Console/EventCacheCommand.php +++ b/src/Illuminate/Foundation/Console/EventCacheCommand.php @@ -3,18 +3,22 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; +use Illuminate\Console\ConfirmableTrait; use Illuminate\Foundation\Support\Providers\EventServiceProvider; use Symfony\Component\Console\Attribute\AsCommand; #[AsCommand(name: 'event:cache')] class EventCacheCommand extends Command { + use ConfirmableTrait; + /** * The name and signature of the console command. * * @var string */ - protected $signature = 'event:cache'; + protected $signature = 'event:cache + {--force : Force the operation to run when in production}'; /** * The console command description. @@ -30,6 +34,10 @@ class EventCacheCommand extends Command */ public function handle() { + if (! $this->confirmToProceed()) { + return; + } + $this->callSilent('event:clear'); file_put_contents( diff --git a/src/Illuminate/Foundation/Console/RouteCacheCommand.php b/src/Illuminate/Foundation/Console/RouteCacheCommand.php index 9b8632af50b2..00269d4609fe 100644 --- a/src/Illuminate/Foundation/Console/RouteCacheCommand.php +++ b/src/Illuminate/Foundation/Console/RouteCacheCommand.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; +use Illuminate\Console\ConfirmableTrait; use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract; use Illuminate\Filesystem\Filesystem; use Illuminate\Routing\RouteCollection; @@ -11,12 +12,15 @@ #[AsCommand(name: 'route:cache')] class RouteCacheCommand extends Command { + use ConfirmableTrait; + /** - * The console command name. + * The name and signature of the console command. * * @var string */ - protected $name = 'route:cache'; + protected $signature = 'route:cache + {--force : Force the operation to run when in production}'; /** * The console command description. @@ -51,6 +55,10 @@ public function __construct(Filesystem $files) */ public function handle() { + if (! $this->confirmToProceed()) { + return; + } + $this->callSilent('route:clear'); $routes = $this->getFreshApplicationRoutes(); diff --git a/src/Illuminate/Foundation/Console/ViewCacheCommand.php b/src/Illuminate/Foundation/Console/ViewCacheCommand.php index 3eacc26fd769..2e14b89528eb 100644 --- a/src/Illuminate/Foundation/Console/ViewCacheCommand.php +++ b/src/Illuminate/Foundation/Console/ViewCacheCommand.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Console; use Illuminate\Console\Command; +use Illuminate\Console\ConfirmableTrait; use Illuminate\Support\Collection; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Output\OutputInterface; @@ -12,12 +13,15 @@ #[AsCommand(name: 'view:cache')] class ViewCacheCommand extends Command { + use ConfirmableTrait; + /** * The name and signature of the console command. * * @var string */ - protected $signature = 'view:cache'; + protected $signature = 'view:cache + {--force : Force the operation to run when in production}'; /** * The console command description. @@ -33,6 +37,10 @@ class ViewCacheCommand extends Command */ public function handle() { + if (! $this->confirmToProceed()) { + return; + } + $this->callSilent('view:clear'); $this->paths()->each(function ($path) {