Giter VIP home page Giter VIP logo

extractor's Introduction

Extractor library for php

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
);

extractor's People

Contributors

mhor avatar mmoreram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

extractor's Issues

Extract files in a zip to root of a folder?

I have a zip file uploaded to server for automated extract.

the zip file construction is like this:

/file.zip/folder1/image1.jpg
/file.zip/folder1/image2.jpg
/file.zip/folder1/image3.jpg

$specificDirectory = new SpecificDirectory( '/images/upload/' );
$extensionResolver = new ExtensionResolver;
$extractor = new Extractor( $specificDirectory, $extensionResolver );
$archive_list = $extractor->extractFromFile( $destination_file );

But by using the function extractFromFile, it will extract to /images/upload as ff:

/images/upload/folder1/image1.jpg
/images/upload/folder1/image2.jpg
/images/upload/folder1/image3.jpg

Is there any way to extract the files in folder1 to the root of myFolder?

Ideal:

/images/upload/image1.jpg
/images/upload/image2.jpg
/images/upload/image3.jpg

nih?

not asking out of evil, but just out of learning, for reasons when you fork and do your own library

i wonder who was first if @raulfraile or you because i saw this too https://github.com/raulfraile/distill

or these two libs are very different, there was also https://github.com/alchemy-fr/Zippy from @romainneutron

just wondering if it would rather be better to share some components across, though i believe perhaps there was an event in spain about this, i know of the hackayunos in Spain and in Italy they created botrelli bot.

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.