GithubHelp home page GithubHelp logo

archive-bundle's Introduction

#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:

  • 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');
}

archive-bundle's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.