2017 © Pedro Peláez
 

symfony-bundle archive-bundle

Symfony2 bundle providing a service for archiving/compressing files

image

ornj/archive-bundle

Symfony2 bundle providing a service for archiving/compressing files

  • Saturday, May 18, 2013
  • by ornj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

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., (*1)

Installation

Install this bundle in your Symfony2 project by adding it to your composer.json., (*2)

{
    "require": {
        "ornj/archive-bundle": "dev-master"
    }
}

After updating composer, register the bundle in app/AppKernel.php., (*3)

$bundles = array(
   // ...
   new Ornj\Bundle\OrnjArchiveBundle\OrnjArchiveBundle(),
);

Usage

The service currently has a single method create which takes an array containing the following parameters:, (*4)

  • string filename: the name of the resulting archive
  • array files: paths to the files that should be contained in the archive
  • string destination: where to write the archive (if none is supplied, web/uploads will be used)
  • bool overwrite: 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');
}

The Versions

18/05 2013

dev-master

9999999-dev

Symfony2 bundle providing a service for archiving/compressing files

  Sources   Download

MIT

The Requires

 

file files zip archive compress