You've already forked Atomcms-edit
Initial commit
This commit is contained in:
Executable
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
class SystemCheck
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$checks = [];
|
||||
|
||||
// 1. Check .env exists
|
||||
if (! file_exists(base_path('.env'))) {
|
||||
if (file_exists(base_path('.env.example'))) {
|
||||
copy(base_path('.env.example'), base_path('.env'));
|
||||
Artisan::call('key:generate', ['--no-interaction' => 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user