container = new Container(); $this->router = new Router(); $this->router->setContainer($this->container); // Register core services $this->registerServices(); } public function run(): 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); } } } }