3 namespace Cli\Services;
9 protected ZipArchive $zip;
10 public function __construct(
11 protected string $filePath
13 $this->zip = new ZipArchive();
14 $status = $this->zip->open($this->filePath);
16 if (!file_exists($this->filePath) || $status !== true) {
17 throw new \Exception("Could not open file [{$this->filePath}] as ZIP");
22 * @return array<string, array{desc: string, exists: bool}>
24 public function getContentsOverview(): array
28 'desc' => '.env Config File',
29 'exists' => boolval($this->zip->statName('.env')),
32 'desc' => 'Themes Folder',
33 'exists' => $this->zip->locateName('/themes/') !== false,
36 'desc' => 'Public File Uploads',
37 'exists' => $this->zip->locateName('/public/uploads/') !== false,
39 'storage/uploads' => [
40 'desc' => 'Private File Uploads',
41 'exists' => $this->zip->locateName('/storage/uploads/') !== false,
44 'desc' => 'Database Dump',
45 'exists' => boolval($this->zip->statName('db.sql')),
50 public function extractInto(string $directoryPath): void
52 $result = $this->zip->extractTo($directoryPath);
54 throw new \Exception("Failed extraction of ZIP into [{$directoryPath}].");