1. Go to this page and download the library: Download victor78/yii2-zipper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
victor78 / yii2-zipper example snippets
return [
//....
'components' => [
'zipper' => [
'class' => 'Victor78\Zipper\Zipper', //12345', //optional, only for 7zip type
],
]
];
//files to archive
$files = [
'/path/to/file1',
'/path/to/file2',
];
//to create tar archive
$tarArchive = Yii::$app->zipper->create('/tmp/archive.tar', $files, true, 'tar');
//to create zip archive by 7zip with password
$sevenZipArchive = Yii::$app->zipper->create('/tmp/archive.zip', $files, true, '7zip', 'password12345');
//or, if you've configured zipper component like in the example above:
$sevenZipArchive = Yii::$app->zipper->create('/tmp/archive.zip', $files);
$zipArchive = Yii::$app->zipper->create('/tmp/archive.zip', $files, true, 'zip');