addArgument( 'name', InputArgument::REQUIRED, 'The name of the project (as used when running spin:up).' ); } protected function execute(InputInterface $input, OutputInterface $output): int { if (parent::execute($input, $output)) { return Command::FAILURE; } $this->config = new Config($input->getArgument('name')); if (!file_exists($this->config->getDataDirectory())) { $this->style->error('No project found with the provided name.'); return Command::FAILURE; } try { passthru($this->buildDockerComposeCommand('down', false, false)); recursive_rmdir($this->config->getDataDirectory()); } catch (\Exception $exception) { $this->style->error('An error occurred while destroying the project: ' . $exception->getMessage()); return Command::FAILURE; } return Command::SUCCESS; } } function recursive_rmdir(string $dir): void { if (!is_dir($dir)) return; $items = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST ); foreach ($items as $item) { $item->isDir() ? rmdir($item->getPathname()) : unlink($item->getPathname()); } rmdir($dir); }