@@ -358,19 +358,57 @@ protected function buildDeploymentCommands(string $repoUrl, string $siteDir, str
358358 $ commands [] = "if [ -d public ] && [ ! -L public_html ] && [ ! -d public_html ]; then ln -s public public_html; fi " ;
359359
360360 // Generate app key ONLY if APP_KEY is not set in .env
361- // Check if .env exists AND if APP_KEY line exists and is not empty
362- $ commands [] = "if [ -f .env ] && ! grep -q '^APP_KEY=base64:' .env 2>/dev/null && ! grep -q '^APP_KEY= \"base64:' .env 2>/dev/null; then php artisan key:generate --quiet; fi " ;
361+ $ commands [] = "if ! grep -q '^APP_KEY=base64:' .env 2>/dev/null && ! grep -q '^APP_KEY= \"base64:' .env 2>/dev/null; then php artisan key:generate --quiet; fi " ;
363362
364- // Run migrations only if .env exists (app is configured)
363+ // Run migrations
365364 if (config ('hostinger-deploy.deployment.run_migrations ' , true )) {
366- $ commands [] = "if [ -f .env ]; then echo 'yes' | php artisan migrate --quiet; fi " ;
365+ $ commands [] = "echo 'yes' | php artisan migrate --quiet " ;
367366 }
368367
369368 // Create storage link only if it doesn't exist
370369 if (config ('hostinger-deploy.deployment.run_storage_link ' , true )) {
371370 $ commands [] = "if [ -d public ] && [ ! -L public/storage ] && [ ! -d public/storage ]; then php artisan storage:link --quiet; fi " ;
372371 }
373372
373+ // Post-deployment optimization commands
374+ // Clear and cache configuration
375+ if (config ('hostinger-deploy.deployment.run_config_cache ' , false )) {
376+ $ commands [] = "php artisan config:clear --quiet " ;
377+ $ commands [] = "php artisan config:cache --quiet " ;
378+ }
379+
380+ // Clear and cache routes
381+ if (config ('hostinger-deploy.deployment.run_route_cache ' , false )) {
382+ $ commands [] = "php artisan route:clear --quiet " ;
383+ $ commands [] = "php artisan route:cache --quiet " ;
384+ }
385+
386+ // Clear and cache views
387+ if (config ('hostinger-deploy.deployment.run_view_cache ' , false )) {
388+ $ commands [] = "php artisan view:clear --quiet " ;
389+ $ commands [] = "php artisan view:cache --quiet " ;
390+ }
391+
392+ // Optimize application (always run)
393+ $ commands [] = "php artisan optimize:clear --quiet " ;
394+ $ commands [] = "php artisan optimize --quiet " ;
395+
396+ // Clear and cache events (if available)
397+ $ commands [] = "php artisan event:clear --quiet || true " ;
398+ $ commands [] = "php artisan event:cache --quiet || true " ;
399+
400+ // Restart queue workers (if using queues)
401+ $ commands [] = "php artisan queue:restart --quiet || true " ;
402+
403+ // Restart Horizon (if using Laravel Horizon)
404+ $ commands [] = "php artisan horizon:terminate --quiet || true " ;
405+
406+ // Clear application cache
407+ $ commands [] = "php artisan cache:clear --quiet " ;
408+
409+ // Clear OPcache (if available)
410+ $ commands [] = "php artisan opcache:clear --quiet || true " ;
411+
374412 return $ commands ;
375413 }
376414
0 commit comments