diff --git a/config/docker-compose.yml b/config/docker-compose.yml new file mode 100644 index 0000000..7cc0ae3 --- /dev/null +++ b/config/docker-compose.yml @@ -0,0 +1,38 @@ +version: "3.9" + +services: + nginx: + build: + context: ./nginx + ports: + - ${NGINX_PORT}:80 + volumes: + - ${PROJECT_DIRECTORY}:/var/www/html:cached + - ./nginx/conf.d:/etc/nginx/conf.d + php: + build: + context: ./php-fpm + working_dir: /var/www/html + extra_hosts: + - host.docker.internal:host-gateway + volumes: + - ${PROJECT_DIRECTORY}:/var/www/html:cached + ports: + - ${PHP_PORT}:9003 + database: + image: mysql:8.0 + command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci + ports: + - ${MYSQL_PORT}:3306 + expose: + - "3306" + environment: + MYSQL_ROOT_PASSWORD: docker + volumes: + - ./data/${PROJECT_NAME}/mysql:/var/lib/mysql:cached + cache: + image: redis:latest + ports: + - ${REDIS_PORT}:6379 + volumes: + - ./data/${PROJECT_NAME}/redis:/data:cached \ No newline at end of file diff --git a/src/Classes/Collection/FilePathCollection.php b/src/Classes/Collection/FilePathCollection.php new file mode 100644 index 0000000..335b06c --- /dev/null +++ b/src/Classes/Collection/FilePathCollection.php @@ -0,0 +1,25 @@ +items[$key] ?? null; + } +} \ No newline at end of file diff --git a/src/Classes/File/SpinnerFilePath.php b/src/Classes/File/SpinnerFilePath.php new file mode 100644 index 0000000..c148cf8 --- /dev/null +++ b/src/Classes/File/SpinnerFilePath.php @@ -0,0 +1,15 @@ +rootDirectory = dirname(__DIR__, 2); $this->system = new System(); + $this->setFilePaths(); parent::__construct(); } - protected function setStyle(InputInterface $input, OutputInterface $output): void + protected function execute(InputInterface $input, OutputInterface $output): int + { + $this->setStyle($input, $output); + + if (!$this->system->isDockerEngineRunning()) { + $this->style->error('It looks like the Docker Engine is not running. Please start it and try again.'); + + return Command::FAILURE; + } + + if ($input->hasArgument('path')) { + $projectDirectory = new FilePath($input->getArgument('path')); + + if (!$projectDirectory->exists() || !$projectDirectory->isDirectory()) { + $this->style->error('The provided path is not a valid directory.'); + + return Command::FAILURE; + } + + $this->filePaths->add($projectDirectory, 'project'); + } + + return Command::SUCCESS; + } + + private function setStyle(InputInterface $input, OutputInterface $output): void { $this->style = new SymfonyStyle($input, $output); } + + private function setFilePaths(): void + { + $this->filePaths = new FilePathCollection([ + 'config' => new SpinnerFilePath('config'), + ]); + } } \ No newline at end of file diff --git a/src/Command/Interface/ConsoleCommandInterface.php b/src/Command/Interface/ConsoleCommandInterface.php new file mode 100644 index 0000000..13854cd --- /dev/null +++ b/src/Command/Interface/ConsoleCommandInterface.php @@ -0,0 +1,8 @@ +setStyle($input, $output); - - $projectDirectory = new FilePath($input->getArgument('path')); - - if (!$projectDirectory->exists() || !$projectDirectory->isDirectory()) { - $this->style->error('The provided path is not a valid directory.'); - - return Command::FAILURE; - } - - if (!$this->system->isDockerEngineRunning()) { - $this->style->error('It looks like the Docker Engine is not running. Please start it and try again.'); - + if (!parent::execute($input, $output)) { return Command::FAILURE; }