Skip to content

z0dd/ExportHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

ExportHelper

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.zip

And 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);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages