Zippy

PHP zip/tar/bz2 archives (de)compression library with commandline or extensions

  • Owner: alchemy-fr/Zippy
  • Platform:
  • License:: Other
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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.

Main metrics

Overview
Name With Owneralchemy-fr/Zippy
Primary LanguagePHP
Program languagePHP (Language Count: 4)
Platform
License:Other
所有者活动
Created At2012-11-19 17:31:19
Pushed At2023-12-20 14:10:28
Last Commit At2021-04-13 16:13:44
Release Count21
Last Release Name1.0.0 (Posted on )
First Release Name0.1.0 (Posted on )
用户参与
Stargazers Count471
Watchers Count19
Fork Count106
Commits Count438
Has Issues Enabled
Issues Count82
Issue Open Count40
Pull Requests Count69
Pull Requests Open Count5
Pull Requests Close Count17
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private