https://github.com/mmoreram/extractor
Compressed files extractor for PHP
https://github.com/mmoreram/extractor
php rar tar zip
Last synced: 11 months ago
JSON representation
Compressed files extractor for PHP
- Host: GitHub
- URL: https://github.com/mmoreram/extractor
- Owner: mmoreram
- License: mit
- Created: 2014-08-29T19:58:08.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2020-05-14T11:08:38.000Z (about 6 years ago)
- Last Synced: 2025-06-25T22:49:09.145Z (12 months ago)
- Topics: php, rar, tar, zip
- Language: PHP
- Size: 41 KB
- Stars: 21
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
Extractor library for php
=========================
This library extracts your files from compressed packages and returns a Symfony
Finder instance, ready to be managed
[](https://insight.sensiolabs.com/projects/6de61eb0-a424-48bc-9683-24252bd7b0d5)
[](https://packagist.org/packages/mmoreram/extractor)
# 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.
* [](https://packagist.org/packages/mmoreram/extractor)
[](https://packagist.org/packages/mmoreram/extractor)
## Installing [Extractor](https://github.com/mmoreram/extractor)
You have to add require line into you composer.json file
``` yml
"require": {
"php": ">=5.3.3",
...
"mmoreram/extractor": "dev-master",
}
```
Then you have to use composer to update your project dependencies
``` bash
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar update
```
## Usage
Get a finder instance given a compressed file
``` php
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
``` php
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
``` php
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
);
```