Looking to fine-tune your Laravel optimization process? The new --except option provides surgical precision for skipping specific commands during optimization, giving you greater control over how your application is optimized for different environments and workflows.
// Skip a specific commandphp artisan optimize --except route:cache // Skip by command keyphp artisan optimize --except route // Skip multiple commandsphp artisan optimize:clear --except route,view:cache
This flexible approach allows you to maintain optimization benefits while selectively bypassing problematic or unnecessary steps for specific scenarios.
function deploy_dev() { php artisan optimize --except route:cache} function deploy_staging() { php artisan optimize --except config,route} function optimize_custom() { if [[ $CI_ENVIRONMENT == "testing" ]]; then php artisan optimize --except view:cache,route:cache else php artisan optimize fi}
This approach eliminates the need for creating complex custom scripts or managing multiple separate commands. Instead, you can execute a single command while excluding specific optimization steps that might interfere with your current task. When troubleshooting route-related issues, for example, you can bypass route caching while still leveraging other performance optimizations, streamlining your debugging workflow.