https://github.com/joomla-framework/archive
Joomla Framework Archive Package
https://github.com/joomla-framework/archive
extraction joomla joomla-framework php
Last synced: 9 months ago
JSON representation
Joomla Framework Archive Package
- Host: GitHub
- URL: https://github.com/joomla-framework/archive
- Owner: joomla-framework
- License: gpl-2.0
- Created: 2013-02-24T03:14:00.000Z (over 13 years ago)
- Default Branch: 3.x-dev
- Last Pushed: 2024-12-10T06:59:35.000Z (over 1 year ago)
- Last Synced: 2025-03-24T06:09:16.197Z (about 1 year ago)
- Topics: extraction, joomla, joomla-framework, php
- Language: PHP
- Homepage:
- Size: 5.25 MB
- Stars: 3
- Watchers: 11
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# The Archive Package [](https://github.com/joomla-framework/archive)
[](https://packagist.org/packages/joomla/archive)
[](https://packagist.org/packages/joomla/archive)
[](https://packagist.org/packages/joomla/archive)
[](https://packagist.org/packages/joomla/archive)
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
```php
$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.
```php
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`.
```json
{
"require": {
"joomla/archive": "~3.0"
}
}
```
Alternatively, you can simply run the following from the command line:
```sh
composer require joomla/archive "~3.0"
```
If you want to include the test sources, use
```sh
composer require --prefer-source joomla/archive "~3.0"
```