Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/takuya/php-7z-cmd-wrapper
7z Archiver Command Wrapper
https://github.com/takuya/php-7z-cmd-wrapper
Last synced: 21 days ago
JSON representation
7z Archiver Command Wrapper
- Host: GitHub
- URL: https://github.com/takuya/php-7z-cmd-wrapper
- Owner: takuya
- License: other
- Created: 2021-08-23T01:38:08.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-24T11:14:36.000Z (over 2 years ago)
- Last Synced: 2024-10-13T18:53:19.268Z (about 1 month ago)
- Language: PHP
- Size: 512 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 7-Zip command wrapper for reading
![](https://circleci.com/gh/takuya/php-7z-cmd-wrapper.svg?style=svg)7z command supports several type of archive.
## requirements
```
sudo apt install p7zip-full
```rar will be installed as non-free
```
sudo apt install p7zip-rar # debian non-free
```
## usage
Access with file name.
```php
$a7z = new Archive7zReader("sample.zip");
foreach( $a7z->files() as $name) {
$bin = $a7z->conent($name);
}
```
Access with index.
```php
$a7z = new Archive7zReader("sample.zip");
$bin = $a7z->at(0);
```### limitations
currently, this project aimed at READING archive. write/append not yet.
### character encodings.(reading archive)
`7z` command will encode filenames by shell ENV[LANG].
So we should take care of encoding using shell env LANG='XXX' and php mb_string.cp932(jp/windows/filename) example. #01 using utf8
```php
$a = new Archive7zReader($f);
$a->setLang('ja_JP.UTF8');
$file_name = $a->files()[1];
$file_name = $name = mb_convert_encoding($file_name,"UTF8","UTF8,CP932");
```
cp932(jp/windows/filename) example. #02 using cp932
```php
$a = new Archive7zReader($f);
$a->setLang('ja_JP.SJIS');
$file_name = $a->files()[1];
$file_name = $name = mb_convert_encoding($file_name,"UTF8","CP932");
```## Installation from github
```
[email protected]:takuya/php-7z-cmd-wrapper.git
composer config repositories.takuya/php-7z-cmd-wrapper vcs $repo
composer require takuya/php-7z-cmd-wrapper
```## Installation from packagist
```
composre require takuya/php-7z-cmd-wrapper
```