getConfig(configKey: 'debug'); if ($debug) { $stream = new StreamHandler(stream: dirname(path: __DIR__, levels: 2) . '/bindAPI.log', level: Logger::DEBUG); } else { $stream = new StreamHandler(stream: dirname(path: __DIR__, levels: 2) . '/bindAPI.log', level: Logger::INFO); } $stream->setFormatter(formatter: $formatter); $this->logger = new Logger(name: 'bindAPI'); $this->logger->pushHandler(handler: $stream); $this->logger->debug(message: 'bindAPI started'); $containerBuilder = new ContainerBuilder(); $containerBuilder->addDefinitions([ ConfigController::class => autowire() ->constructorParameter(parameter: 'verbose', value: $verbose), CLIController::class => autowire() ->constructorParameter(parameter: 'logger', value: $this->logger), DomainController::class => autowire() ->constructorParameter(parameter: 'logger', value: $this->logger), DomainRepository::class => autowire() ->constructorParameter(parameter: 'logger', value: $this->logger), DynDnsRepository::class => autowire() ->constructorParameter(parameter: 'logger', value: $this->logger), RequestController::class => autowire() ->constructorParameter(parameter: 'logger', value: $this->logger) ]); $this->container = $containerBuilder->build(); } /** * @throws \DI\DependencyException * @throws \DI\NotFoundException */ public function runCommand(int $argumentsCount, array $arguments): void { $this->logger->debug(message: 'runCommand()'); $cliController = $this->container->get(name: CLIController::class); $cliController->runCommand(argumentsCount: $argumentsCount, arguments: $arguments); } /** * @throws \DI\DependencyException * @throws \DI\NotFoundException */ public function handleRequest(string $requestMethod, array $uri): void { $this->logger->debug(message: 'handleRequest()'); $requestController = $this->container->get(name: RequestController::class); $requestController->handleRequest(requestMethod: $requestMethod, uri: $uri); } }