/** * Instantiate an archive adapter object * * @param \Pop\Archive\Archive $archive * @return Zip */ public function __construct(\Pop\Archive\Archive $archive) { if (strpos($archive->getFullpath(), '/.') !== false) { $this->workingDir = substr($archive->getFullpath(), 0, strpos($archive->getFullpath(), '/.')); } else { if (strpos($archive->getFullpath(), '\\.') !== false) { $this->workingDir = substr($archive->getFullpath(), 0, strpos($archive->getFullpath(), '\\.')); } else { $this->workingDir = getcwd(); } } if (substr($archive->getFullpath(), 0, 1) != '/' && substr($archive->getFullpath(), 1, 1) != ':') { $this->path = $this->workingDir . DIRECTORY_SEPARATOR . $archive->getFullpath(); } else { $this->path = realpath(dirname($archive->getFullpath())) . DIRECTORY_SEPARATOR . $archive->getBasename(); } $this->archive = new \ZipArchive(); }
<?php require_once '../../bootstrap.php'; use Pop\Archive\Archive; try { // Create a new ZIP archive and add some files to it // (Make sure the '../tmp' folder is writable) $archive = new Archive('../tmp/test.zip'); $archive->addFiles('../assets'); // Display the new archive file size echo $archive->getBasename() . ': compressed file size => ' . $archive->getSize() . '<br /> ' . PHP_EOL; echo 'Done.'; } catch (\Exception $e) { echo $e->getMessage() . PHP_EOL . PHP_EOL; }