Commit f7fc7cc3 by Dirk Benkert

added zip creation via system call instead of PHPs ZIP extension

parent ecbafb3b
......@@ -52,5 +52,10 @@ return array(
'default-data' => array(
'base-url' => 'https://www.your-domain.com/path',
)
)
),
'zipper' => array(
//'method' => 'ZipArchive', // ZipArchive relies on PHPs ZIP Extension and is limited by memory_limit and max_execution_time
'method' => 'System', // use following command to create the zip via shellexec
'cmd' => 'zip -rq {{ARCHIVE}} {{SOURCE}}'
),
);
......@@ -54,10 +54,32 @@ class Zipper extends AbstractService {
$this->setArchiveName($folder->label . '.zip');
$path = new Path($this->getServiceLocator());
$this->setArchivePath($path->getBasePath() . DIRECTORY_SEPARATOR . $this->getArchiveName());
$config = $this->getServiceLocator()->get('Config');
if ($config['zipper']['method'] == 'ZipArchive') {
$this->createViaPhp($folder);
}
if ($config['zipper']['method'] == 'System') {
$this->createViaSystem($config['zipper']['cmd'], $folder);
}
}
protected function createViaSystem($cmd, $folder) {
$cmd = str_replace('{{ARCHIVE}}', $this->getArchivePath(), $cmd);
$cmd = str_replace('{{SOURCE}}', dirname($this->getArchivePath()) . DIRECTORY_SEPARATOR . $folder->name, $cmd);
$output = array();
exec($cmd, $output, $return);
$this->setArchiveSize(filesize($this->getArchivePath()));
}
protected function createViaPhp($folder) {
$files = $this->getFiles($folder);
$this->setArchivePath($path->getBasePath() . DIRECTORY_SEPARATOR . $this->getArchiveName());
$zip = new ZipArchive();
$zip->open($this->getArchivePath(), ZipArchive::CREATE);
foreach ($files as $file) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment