-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 64e40d1
Showing
15 changed files
with
10,824 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.