Simple class for easy create ZIP archives with CSV files.
Include class:
require "ExportModule.php";
$exportModule = new ExportModule;You can add some settings:
$exportModule->setMemoryLimit("512M");
$exportModule->setDelimeter(';');
$exportModule->setEnclosure('"');
$exportModule->setChmodMode(0755);
$exportModule->setSavePath('/var/www/repo');And you can get them:
$exportModule->getSavePath();Add some text data:
$data = [
['foo', 'bar', 'baz', 'qwe', 'asd', 'zxc'], //row
['foo', 'bar', 'baz', 'qwe', 'asd', 'zxc'], //another one
['foo', 'bar', 'baz', 'qwe', 'asd', 'zxc'], //...
];
$exportModule->addFile($data);You can add a specific file to:
$exportModule->addSpecificFile($filepath);And more...
$exportModule
->addSpecificFile($someFile)
->addFile($fooData)
->addFile($barData)
->addFile($bazData)
->addSpecificFile($anotherFile);And get you archive
echo $exportModule->makeZip('archive.zip'); // /var/www/repo/archive.zipAnd you can download it forcefully:
$exportModule->downloadArchive();Or use it in case:
$exportModule
->addFile($foo)
->addFile($bar)
->makeZip();
$exportModule->downloadArchive();You can use static func to force download any files
ExportModule::forceDownload($filename);