Git Product home page Git Product logo

zippy's Introduction

Zippy

License Packagist Travis Scrutinizer Packagist

A PHP library to read, create, and extract archives in various formats via command line utilities or PHP extensions

Installation

The only supported installation method is via Composer. Run the following command to require Zippy in your project:

composer require alchemy/zippy

Adapters

Zippy currently supports the following drivers and file formats:

  • zip
    • .zip
  • PHP zip extension
    • .zip
  • GNU tar
    • .tar
    • .tar.gz
    • .tar.bz2
  • BSD tar
    • .tar
    • .tar.gz
    • .tar.bz2

Getting started

All the following code samples assume that Zippy is loaded and available as $zippy. You need the following code (or variation of) to load Zippy:

<?php

use Alchemy\Zippy\Zippy;

// Require Composer's autoloader
require __DIR__ . '/vendor/autoload.php';

// Load Zippy
$zippy = Zippy::load();

List an archive's contents:

// Open an archive
$archive = $zippy->open('build.tar');

// Iterate through members
foreach ($archive as $member) {
    echo "Archive contains $member" . PHP_EOL;
}

Extract an archive to a specific directory:

// Open an archive
$archive = $zippy->open('build.tar');

// Extract archive contents to `/tmp`
$archive->extract('/tmp');

Create a new archive

// Creates an archive.zip that contains a directory "folder" that contains
// files contained in "/path/to/directory" recursively
$archive = $zippy->create('archive.zip', array(
    'folder' => '/path/to/directory'
), true);

Customize file and directory names inside archive

$archive = $zippy->create('archive.zip', array(
    'folder' => '/path/to/directory',            // will create a folder at root
    'http://www.google.com/logo.jpg',            // will create a logo.jpg file at root
    fopen('https://www.facebook.com/index.php'), // will create an index.php at root
    'directory/image.jpg' => 'image.jpg',        // will create a image.jpg in 'directory' folder
));

Documentation

Documentation hosted at read the docs !

License

This project is licensed under the MIT license.

zippy's People

Contributors

romainneutron avatar nlegoff avatar aztech-dev avatar aynsix avatar fabre-thibaud avatar nmaillat avatar shanecp avatar giantcowfilms avatar joachimdoerr avatar max-kovpak avatar yosmanyga avatar bburnichon avatar bitdeli-chef avatar jducro avatar koc avatar pgodel avatar pborreli avatar paulredmond avatar mykiwi avatar scrutinizer-auto-fixer avatar fanno avatar jygaulier avatar

Watchers

James Cloos 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.