ornj / archive-bundle
Symfony2 bundle providing a service for archiving/compressing files
dev-master
2013-05-17 23:04 UTC
Requires
- php: >=5.3.0
- symfony/symfony: 2.1.*
This package is not auto-updated.
Last update: 2026-03-09 21:59:52 UTC
README
#Ornj ArchiveBundle
This bundle provides a service for creating a zip archive of files on the filesystem. This is useful for delivering multiple files as a single download. At the moment the only supported compression type is Zip through PHP's ZipArchive although I indend to expand it to support other formats.
Installation
Install this bundle in your Symfony2 project by adding it to your composer.json.
{
"require": {
"ornj/archive-bundle": "dev-master"
}
}
After updating composer, register the bundle in app/AppKernel.php.
$bundles = array( // ... new Ornj\Bundle\OrnjArchiveBundle\OrnjArchiveBundle(), );
Usage
The service currently has a single method create which takes an array containing the following parameters:
stringfilename: the name of the resulting archivearrayfiles: paths to the files that should be contained in the archivestringdestination: where to write the archive (if none is supplied, web/uploads will be used)booloverwrite: if the service should write over any archive with the same file name
$archive = $this->get('ornj_archive.zip'); $created = $archive->create(array( 'files' => $files, 'filename' => $entity->getId() . '.zip', 'destination' => $basePath. '/archives/', 'overwrite' => false )); if ($created === true) { return $this->redirect($webPath. '/archives/' . $entity->getId() . '.zip'); }