2017 © Pedro Peláez
 

library archive-tar

Archive TAR reader for PHP - supports gz, bz2 and files over 2 GB

image

mishak/archive-tar

Archive TAR reader for PHP - supports gz, bz2 and files over 2 GB

  • Friday, April 1, 2016
  • by mishak87
  • Repository
  • 2 Watchers
  • 12 Stars
  • 108 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 1 Open issues
  • 5 Versions
  • 6 % Grown

The README.md

Archive TAR Reader for PHP

Simple tool for reading TAR archives in PHP. Supports records with size larger then PHP_INT_MAX (slightly less then 2 GB)., (*1)

Supports only USTAR format. This should be the most used TAR format after 1988., (*2)

Gz and bz2 compressions are transparently supported via detection from filename extension., (*3)

Installation

Add to your composer.json requirement "mishak/archive-tar": "dev-master"., (*4)

Examples

List all records in archive

$filename = 'archive.tar';
$reader = new Mishak\ArchiveTar\Reader($filename);
$read->setBuffer(PHP_INT_MAX);
$read->setReadContents(FALSE);
foreach ($reader as $record) {
    print_r($record);
}
$filename = 'archive.tar';
$reader = new Mishak\ArchiveTar\Reader($filename);
foreach ($reader as $record) {
    if (in_array($record['type'], array(\Mishak\ArchiveTar\Reader::REGULAR, \Mishak\ArchiveTar\Reader::AREGULAR), TRUE)) {
        echo $record['filename'], "\n";
        echo $record['contents'], "\n";
    }
}

This will produce exactly same output as previous example., (*5)

$filename = 'archive.tar';
$reader = new Mishak\ArchiveTar\Reader($filename);
$lastRecord = NULL;
$read->setReadContents(function ($record, $chunk, $left, $read) use ($lastRecord) {
    if (!in_array($record['type'], array(\Mishak\ArchiveTar\Reader::REGULAR, \Mishak\ArchiveTar\Reader::AREGULAR), TRUE)) {
        continue;
    }
    if (NULL === $lastRecord || $record['filename'] !== $lastRecord['filename']) {
        if (NULL !== $lastRecord) {
            echo "\n";
        }
        echo $record['filename'], "\n";
    }
    echo $chunk;
    if (!$left) {
        echo "\n";
    }
}
});
foreach ($reader as $record) {
    // don't mind just walking thru...
}

The Versions

01/04 2016

dev-master

9999999-dev

Archive TAR reader for PHP - supports gz, bz2 and files over 2 GB

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

  • php >=5.3.0

 

archive reader tar

01/04 2016

v1.1.0

1.1.0.0

Archive TAR reader for PHP - supports gz, bz2 and files over 2 GB

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

  • php >=5.3.0

 

archive reader tar

27/09 2013

dev-xz_support

dev-xz_support

Archive TAR reader for PHP - supports gz, bz2 and files over 2 GB

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

  • php >=5.3.0

 

archive reader tar

27/09 2013

dev-filters_instead_of_functions

dev-filters_instead_of_functions

Archive TAR reader for PHP - supports gz, bz2 and files over 2 GB

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

  • php >=5.3.0

 

archive reader tar

27/09 2013

v1.0.0

1.0.0.0

Archive TAR reader for PHP - supports gz, bz2 and files over 2 GB

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

  • php >=5.3.0

 

archive reader tar