From e1c2ef46c517f804554753c6dfbb2a4de79d6708 Mon Sep 17 00:00:00 2001 From: Bruno Eckhardt Date: Fri, 22 May 2026 12:49:04 +0200 Subject: [PATCH] sehr gutes init --- init.php | 235 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 212 insertions(+), 23 deletions(-) diff --git a/init.php b/init.php index 9271fe8..c92c0e2 100644 --- a/init.php +++ b/init.php @@ -34,6 +34,7 @@ $dirs = [ 'WEBROOT/src/utils', 'WEBROOT/src/MVC', 'WEBROOT/src/MVC/Core', + 'WEBROOT/src/MVC/Classes', 'WEBROOT/src/MVC/Controller', 'WEBROOT/src/MVC/Model', 'WEBROOT/src/MVC/View', @@ -369,10 +370,16 @@ PHP; $files['WEBROOT/src/config/env.ini'] = << $statusCode === 200 ? 'success' : 'error', + 'data' => $data, + ], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE + ); + exit; + } +} +PHP; + +$files['WEBROOT/src/MVC/Classes/Client.php'] = <<<'PHP' +country ?? 'UNKNOWN'; + } + + public static function userAgent() { + return $_SERVER['HTTP_USER_AGENT'] ?? 'UNKNOWN'; + } +} +PHP; + +$files['WEBROOT/src/MVC/Classes/Cookie.php'] = <<<'PHP' + @@ -692,10 +842,31 @@ $files['WEBROOT/src/MVC/Layout/Templates/main.php'] = <<<'HTML' HTML; // --- CONTROLLERS --- +$files['WEBROOT/src/MVC/Controller/ApiController.php'] = <<<'PHP' + 'DummyData', + ]); + } +} +PHP; + $files['WEBROOT/src/MVC/Controller/HomeController.php'] = <<<'PHP' Dashboard

Willkommen in deinem neuen MVC-System mit integriertem Header.

"; -$files['WEBROOT/src/MVC/View/test1.php'] = "

Service 1

"; -$files['WEBROOT/src/MVC/View/test2.php'] = "

System Check

"; - // --- API --- $files['WEBROOT/api/v1/get.php'] = <<<'PHP' 'online' - ] -); +require_once __DIR__ . '/../../src/MVC/autoloader.php'; + +use MVC\Controller\ApiController; + +$api = (new ApiController()); + +try { + echo ($api->get()); +} catch (\Exception $e) { + echo ($e->getMessage()); +} PHP; + +// --- VIEWS --- +$files['WEBROOT/src/MVC/View/home.php'] = "

Dashboard

Willkommen in deinem neuen MVC-System mit integriertem Header.

"; +$files['WEBROOT/src/MVC/View/test1.php'] = "

Service 1

"; +$files['WEBROOT/src/MVC/View/test2.php'] = "

System Check

"; + // --- ENTRY POINT --- $files['WEBROOT/index.php'] = <<<'PHP' '🏠 Home', + 'test1' => '🛠️Test 1', + 'test2' => '📊 Test 2', + ]; ?> setBlock('sidebar', ob_get_clean()); @@ -918,6 +1105,10 @@ $controllerContent = <<add('{$key}', \\MVC\\Controller\\{$className}Controller::class, '{$key}', ['auth']);\n\n"; -echo "2. Füge den Service in der Seitenverwaltung (Admin) oder in config.php hinzu:\n"; -echo " ID: {$key}\n"; -echo " Name: " . ucfirst($name) . "\n"; echo "------------------------\n"; PHP; @@ -982,6 +1170,7 @@ foreach ($files as $file => $content) { echo "📄 Datei erstellt: $file\n"; } -echo "\n✨ Projekt '$projectName' wurde mit HEADER initialisiert!\n"; -echo "1. Starten: php server.php\n"; -echo "2. Öffnen: http://localhost:8000\n"; \ No newline at end of file +echo "\n✨ Projekt '$projectName' wurde initialisiert!\n"; +echo "1. Richte deine Datenbankverbindung in WEBROOT/src/config/env.ini ein.\n"; +echo "2. Starten: php server.php\n"; +echo "3. Öffnen: http://localhost:8000\n"; \ No newline at end of file