Backup #816

ID816
Dateipfad/var/www/dev.campus.systemische-tools.de/src/Framework/App.php
Version4
Typ modified
Größe1.6 KB
Hashead9877a2e278b075fb235237f72a4c123e756c24151cf05dea97f9d5d1905e3
Datum2025-12-23 08:09:00
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

namespace Framework;

use Framework\Middleware\CorrelationMiddleware;

class App
{
    protected Router $router;
    protected Container $container;

    public function __construct()
    {
        $this->container = new Container();
        $this->router = new Router();
        $this->router->setContainer($this->container);

        // Register core services
        $this->registerServices();
    }

    public function run(): void
    {
        // Run middleware chain
        $middleware = new CorrelationMiddleware();
        $middleware->handle(fn () => $this->dispatch());
    }

    /**
     * Dispatch the request to the router.
     */
    protected function dispatch(): void
    {
        $uri = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH);
        $method = $_SERVER['REQUEST_METHOD'] ?? 'GET';

        $this->router->dispatch($uri ?? '/', $method);
    }

    public function router(): Router
    {
        return $this->router;
    }

    public function container(): Container
    {
        return $this->container;
    }

    /**
     * Register core services in the container.
     *
     * Explicit registrations override autowiring.
     * Services without registration will be autowired.
     */
    protected function registerServices(): void
    {
        // Load service definitions if file exists
        $servicesFile = dirname(__DIR__) . '/services.php';
        if (file_exists($servicesFile)) {
            $configure = require $servicesFile;
            if (is_callable($configure)) {
                $configure($this->container);
            }
        }
    }
}

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
1305 7 modified 1.7 KB 2025-12-25 13:29
1290 6 modified 2.1 KB 2025-12-25 13:17
1289 5 modified 1.7 KB 2025-12-25 13:10
816 4 modified 1.6 KB 2025-12-23 08:09
525 3 modified 1.3 KB 2025-12-22 16:47
492 2 modified 466 B 2025-12-22 15:30
401 1 modified 443 B 2025-12-22 08:53

← Zurück zur Übersicht