Skip to content

Conversation

@yousefkadah
Copy link

Description

This PR adds confirmation prompts to cache commands (config:cache, route:cache, view:cache, and event:cache) to prevent accidental cache regeneration in production environments.

Motivation

Cache commands can silently break applications in production if there are serialization issues or configuration errors. Currently, these commands execute immediately without any warning or confirmation, which poses a risk when run in production environments.

Changes

  • Added ConfirmableTrait to ConfigCacheCommand, RouteCacheCommand, ViewCacheCommand, and EventCacheCommand
  • Added --force option to all cache commands to bypass confirmation prompts
  • Converted $name property to $signature to support command options
  • Added confirmToProceed() check before cache operations execute

Behavior

In production environments:

  • Commands now display an alert: "Application In Production"
  • Prompts user: "Are you sure you want to run this command?"
  • User can confirm (Yes) or cancel (No)
  • If cancelled, displays "Command cancelled" and exits

In development/testing environments:

  • No change in behavior - commands execute immediately without prompts

In CI/CD pipelines:

  • Use --force flag to bypass prompts: php artisan config:cache --force

Examples

# Production environment - will prompt for confirmation
APP_ENV=production php artisan config:cache

# Production environment - skip confirmation with --force
APP_ENV=production php artisan config:cache --force

# Development environment - no prompt (existing behavior)
php artisan config:cache

This commit adds the ConfirmableTrait to config:cache, route:cache,
view:cache, and event:cache commands to prevent accidental cache
regeneration in production environments.

Changes:
- Added ConfirmableTrait to all cache commands
- Added --force option to bypass confirmation prompts
- Converted $name property to $signature to support options
- Added confirmToProceed() check before cache operations

The confirmation prompt only appears when running in production
environment, following the same pattern used in other destructive
commands like key:generate.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants