mmoreram/extractor

Extractor project for php

1.2.1 2018-12-17 08:46 UTC

This package is auto-updated.

Last update: 2024-10-29 04:19:57 UTC


README

This library extracts your files from compressed packages and returns a Symfony Finder instance, ready to be managed

SensioLabsInsight License

Installing/Configuring

Tags

  • Use last unstable version ( alias of dev-master ) to stay in last commit
  • Use last stable version tag to stay in a stable release.
  • Latest Unstable Version Latest Stable Version

Installing Extractor

You have to add require line into you composer.json file

"require": {
    "php": ">=5.3.3",
    ...

    "mmoreram/extractor": "dev-master",
}

Then you have to use composer to update your project dependencies

$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar update

Usage

Get a finder instance given a compressed file

<?php

use Symfony\Component\Finder\Finder;
use Mmoreram\Extractor\Filesystem\TemporaryDirectory;
use Mmoreram\Extractor\Resolver\ExtensionResolver;
use Mmoreram\Extractor\Extractor;

$temporaryDirectory = new TemporaryDirectory();
$extensionResolver = new ExtensionResolver;
$extractor = new Extractor(
    $temporaryDirectory,
    $extensionResolver
);

/**
 * @var Finder $files
 */
$files = $extractor->extractFromFile('/tmp/myfile.rar');
foreach ($files as $file) {

    echo $file->getRealpath() . PHP_EOL;
}

Adapters

This library currently manages these extensions. All of these adapters only works if the php extension is installed.

Directories

This library provide the way of working with temporary and specific directories.

Temporary directory

use Mmoreram\Extractor\Filesystem\TemporaryDirectory;
use Mmoreram\Extractor\Resolver\ExtensionResolver;
use Mmoreram\Extractor\Extractor;

$temporaryDirectory = new TemporaryDirectory();
$extensionResolver = new ExtensionResolver;
$extractor = new Extractor(
    $temporaryDirectory,
    $extensionResolver
);

Specific directory

use Mmoreram\Extractor\Filesystem\SpecificDirectory;
use Mmoreram\Extractor\Resolver\ExtensionResolver;
use Mmoreram\Extractor\Extractor;

$specificDirectory = new SpecificDirectory('/my/specific/path');
$extensionResolver = new ExtensionResolver;
$extractor = new Extractor(
    $specificDirectory,
    $extensionResolver
);