joomla / archive
Joomla Archive Package
Fund package maintenance!
joomla
community.joomla.org/sponsorship-campaigns.html
Installs: 236 739
Dependents: 4
Suggesters: 1
Security: 2
Stars: 3
Watchers: 13
Forks: 9
Open Issues: 1
Type:joomla-package
Requires
- php: ^8.1.0
- joomla/filesystem: ^3.0
Requires (Dev)
- joomla/test: ^3.0
- phan/phan: ^5.4.2
- phpstan/phpstan: ^1.10.7
- phpunit/phpunit: ^9.5.28
- squizlabs/php_codesniffer: ~3.7.2
- dev-3.x-dev / 3.0.x-dev
- 3.0.2
- 3.0.1
- 3.0.0
- dev-2.0-dev / 2.0.x-dev
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0-rc
- 2.0.0-beta5
- 2.0.0-beta4
- 2.0.0-beta3
- 2.0.0-beta2
- 2.0.0-beta
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0
- 1.0-beta3
- 1.0-beta2
- 1.0-beta
- 1.0-alpha
- dev-4.x-dev
- dev-php-8.2
- dev-1.x-dev
This package is auto-updated.
Last update: 2024-11-08 21:24:03 UTC
README
The archive package will intelligently load the correct adapter for the specified archive type. It knows how to properly handle the following archive types:
- zip
- tar | tgz | tbz2
- gz | gzip
- bz2 | bzip2
Loading files of the t*
archive type will uncompress the archive using the appropriate adapter, and then extract via tar.
Requirements
- PHP 8.1 or later
- zlib extension for GZip support
- bz2 extension for BZip2 support
Usage
$options = array('tmp_path' => '/tmp'); $archive = new Joomla\Archive\Archive($options) $archive->extract(__DIR__ . '/archive.zip', __DIR__ . '/destination');
Overriding Adapters
If you have a custom adapter you would like to use for extracting, this package allows you to override the defaults. Just implement ExtractableInterface
when creating your adapter, and then use the setAdapter
method to override.
class MyZipAdapter implements \Joomla\Archive\ExtractableInterface { public static function isSupported() { // Do you test return true; } public function extract($archive, $destination) { // Your code } } $archive = new Archive; // You need to pass the fully qualified class name. $archive->setAdapter('zip', '\\MyZipAdapter'); // This will use your $archive->extract('archive.zip', 'destination');
Installation via Composer
Add "joomla/archive": "~3.0"
to the require block in your composer.json and then run composer install
.
{ "require": { "joomla/archive": "~3.0" } }
Alternatively, you can simply run the following from the command line:
composer require joomla/archive "~3.0"
If you want to include the test sources, use
composer require --prefer-source joomla/archive "~3.0"