info('Downloading ZIP file...'); $zipContent = file_get_contents($zipUrl); file_put_contents($localZipPath, $zipContent); // Check if the ZIP file was successfully downloaded if (!file_exists($localZipPath)) { $this->error('Failed to download the ZIP file.'); return; } // Unzipping the file $this->info('Unzipping the file...'); $zip = new \ZipArchive(); if ($zip->open($localZipPath) === TRUE) { // Create the extraction directory if it doesn't exist if (!file_exists($extractPath)) { mkdir($extractPath, 0777, true); } // Extract the ZIP file to the specified directory $zip->extractTo($extractPath); $zip->close(); $this->info('File unzipped successfully.'); } else { $this->error('Failed to unzip the file.'); } // Optionally, delete the zip file after extraction unlink($localZipPath); } }