Skip to content

Commit

Permalink
publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
insign committed Mar 23, 2024
0 parents commit 64e40d1
Show file tree
Hide file tree
Showing 15 changed files with 10,824 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name : PHPUnit Test

on :
push :
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs :
test:

runs-on: ubuntu-latest

steps :
-
name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

-
uses: actions/checkout@v4

-
name: Validate composer.json and composer.lock
run : composer validate --strict

-
name: Cache Composer packages
id : composer-cache
uses: actions/cache@v4
with:
path : vendor
key : ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
-
name: Install dependencies
run : composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

-
name: Run test suite
run : composer run-script test
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test_files/target
test_files/extract
vendor/
.env*
.idea/
.vscode/
node_modules/
.phpunit.result.cache
*.log
.DS_Store
ai.txt
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2024 Hélio Oliveira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# SevenZip 📦

A PHP package to compress and decompress files using 7zip.

![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/verseles/SevenZip/phpunit.yml?style=for-the-badge&label=PHPUnit)

## Installation

Install the package via Composer:

```bash
composer require verseles/sevenzip
```

## Usage

To compress a file or directory:

```php
use Verseles\SevenZip\SevenZip;

$sevenZip = new SevenZip();

$format = '7z'; // Compression format (e.g., '7z', 'zip', 'tar')
$archivePath = '/path/to/archive.7z';
$sourcePath = '/path/to/source/file/or/directory';

$sevenZip->compress($format, $archivePath, $sourcePath);
```

To extract an archive:

```php
use Verseles\SevenZip\SevenZip;

$sevenZip = new SevenZip();

$format = '7z'; // Archive format (e.g., '7z', 'zip', 'tar')
$archivePath = '/path/to/archive.7z';
$extractPath = '/path/to/extract/directory';

$sevenZip->extract($format, $archivePath, $extractPath);
```

## Supported Formats

The package currently supports the following formats for compression and extraction:

- 7z (default to lzma2)
- zip
- tar
- lz4
- lz5
- bzip2
- zstd

## TODO / WIP

- [ ] Add custom support for gz, xz, etc. by using tar flags
- [ ] Use tar to keep original file permissions and other attributes
- [ ] Add extract custom flags

## Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

1. Fork the repository
2. Create a new branch for your feature or bug fix
3. Make your changes and commit them with descriptive commit messages
4. Push your changes to your forked repository
5. Submit a pull request to the main repository

Please ensure that your code follows the project's coding style and conventions. Also, include appropriate tests for your changes.

## Testing

To run the tests, execute the following command:

```bash
make
```

## License

This package is open-sourced software licensed under the [MIT license](./LICENSE.md).
39 changes: 39 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "verseles/sevenzip",
"description": "A package to compress and decompress files using 7zip",
"version": "0.0.3",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Hélio Oliveira",
"email": "[email protected]"
}
],
"require": {
"php": ">=8.2",
"symfony/process": "^6.4"
},
"require-dev": {
"orchestra/testbench": "^8.18",
"phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
"Verseles\\SevenZip\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Verseles\\SevenZip\\Tests\\": "tests/"
}
},
"scripts": {
"test": "vendor/bin/phpunit tests/SevenZipTest.php --testdox"
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Loading

0 comments on commit 64e40d1

Please sign in to comment.