getFilePaths()->get('projectDockerCompose'); if (!$projectDockerCompose instanceof FilePath) { throw new \Exception('Project Docker Compose file path not found.'); } return parent::__construct($projectDockerCompose, $config); } /** * @throws \Exception */ public function build(InputInterface $input): DockerComposeFileBuilder { $this->content = file_get_contents( $this->config->getFilePaths()->get('phpYamlTemplate')->getAbsolutePath() ); if ($this->config->isDatabaseEnabled($input) && in_array($this->config->getDatabaseDriver($input), ['sqlite3', 'sqlite'])) { $this->addSqliteDatabaseConfig(); } if ($this->config->isServerEnabled($input)) { $this->addNginxConfig(); } return $this; } private function addNginxConfig(): void { $this->content .= str_replace( 'services:', '', file_get_contents( $this->config->getFilePaths()->get('nginxYamlTemplate')->getAbsolutePath() ) ); $this->content = str_replace( './nginx/conf.d', (new FilePath('config/nginx/conf.d'))->getAbsolutePath(), $this->content ); } private function addSqliteDatabaseConfig(): void { $sqlLiteConfig = file_get_contents((new FilePath('config/sqlite.yaml'))->getAbsolutePath()); $sqlLiteConfig = str_replace('volumes:', '', $sqlLiteConfig); $this->content .= $sqlLiteConfig; } }