setDescription('Clear application caches (proxy, runtime)'); } public function handle(): void { $basePath = BASE_PATH . '/runtime'; $directories = [ $basePath . '/container/proxy', $basePath . '/container/aspects', $basePath . '/cache', ]; $clearedCount = 0; foreach ($directories as $dir) { if (is_dir($dir)) { $files = glob($dir . '/*'); foreach ($files as $file) { if (is_file($file)) { unlink($file); $clearedCount++; } elseif (is_dir($file)) { $this->removeDirectory($file); $clearedCount++; } } $this->info("Cleared: {$dir}"); } else { $this->line("Skipped (not exists): {$dir}"); } } $this->info("Cache cleared. Removed {$clearedCount} items."); } private function removeDirectory(string $dir): void { if (!is_dir($dir)) { return; } $files = array_diff(scandir($dir), ['.', '..']); foreach ($files as $file) { $path = $dir . '/' . $file; is_dir($path) ? $this->removeDirectory($path) : unlink($path); } rmdir($dir); } }