mmoreram / extractor
Extractor project for php
Installs: 128 599
Dependents: 8
Suggesters: 0
Security: 0
Stars: 21
Watchers: 3
Forks: 6
Open Issues: 0
Requires
- php: >=5.3.3
- symfony/finder: ^2.1|^3.0|^4.0
Suggests
- ext-phar: For usage of Phar adapter
- ext-rar: For usage of Rar adapter
- ext-zip: For usage of Zip adapter
README
This library extracts your files from compressed packages and returns a Symfony Finder instance, ready to be managed
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.
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.
- Zip - http://php.net/manual/en/book.zip.php
- Rar - http://php.net/manual/en/book.rar.php
- Phar - http://php.net/manual/en/book.phar.php
- Tar
- GZ
- BZ2
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 );