true]); $checks[] = 'Created .env from example'; } } // 2. Check APP_KEY if (empty(Config::get('app.key'))) { Artisan::call('key:generate', ['--no-interaction' => true]); $checks[] = 'Generated APP_KEY'; } // 3. Check storage symlink if (! file_exists(public_path('storage'))) { Artisan::call('storage:link'); $checks[] = 'Created storage symlink'; } // 4. Check required PHP extensions $required = ['pdo_mysql', 'curl', 'mbstring', 'openssl', 'tokenizer']; $missing = array_filter($required, fn ($ext) => ! extension_loaded($ext)); if (! empty($missing)) { return response()->json([ 'error' => 'Missing PHP extensions: ' . implode(', ', $missing), 'solution' => 'Install: apt install php-' . implode(' php-', $missing), ], 500); } // 5. Log any auto-fixes if (! empty($checks)) { \Log::info('SystemCheck auto-fixed: ' . implode(', ', $checks)); } return $next($request); } }