2017 © Pedro PelΓ‘ez
 

yii2-extension yii2-zipper

Yii2-Zipper is archiving component for Yii2.

image

victor78/yii2-zipper

Yii2-Zipper is archiving component for Yii2.

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 34 % Grown

The README.md

Yii2-Zipper

Archiving extension for Yii2 Framework - zip, tar, tar.gz, tar.bz2, 7zip (for zip archive with supporting passwords). It's shell over ZippyExt., (*1)

Π Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠ΅ для Π°Ρ€Ρ…ΠΈΠ²Π°Ρ†ΠΈΠΈ Π² Yii2 Framework - Π² Π²ΠΈΠ΄Π΅ zip, tar, tar.gz, tar.bz2, 7zip (Ρ‚ΠΎΠ»ΡŒΠΊΠΎ для zip Π°Ρ€Ρ…ΠΈΠ²Π° - Π² Ρ‚ΠΎΠΌ числС с ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠΎΠΉ ΠΏΠ°Ρ€ΠΎΠ»Π΅ΠΉ)., (*2)

English: * Installation * Configuration * How to use * Requirements, (*3)

Русский: * Установка * Настройка * Как ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ * ВрСбования, (*4)

Installation

The preferred way to install this extension is through composer., (*5)

Either run, (*6)

php composer.phar require --prefer-dist victor78/yii2-zipper:"~0.0.4"

or add, (*7)

"victor78/yii2-zipper": "~0.0.4"

to the require section of your composer.json., (*8)

Configuration

'type' and 'password' are optional., (*9)

return [
    //....
    'components' => [
        'zipper' => [
            'class' => 'Victor78\Zipper\Zipper', //required
            'type' => '7zip', //or 'zip' (default), 'tar', 'tar.gz', 'tar.bz2'
            'password' => 'password12345', //optional, only for 7zip type
        ],
    ]
];

How to use

To create archive:, (*10)

//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'); 

To open archive and extract:, (*11)

$zipArchive = Yii::$app->zipper->open('/tmp/archive.zip', 'zip');
$tarArchive = Yii::$app->zipper->open('/tmp/archive.tar', 'tar');
$sevenZipArchive = Yii::$app->zipper->open('/tmp/archive.zip', '7zip');
//open 7zip with password
$sevenZipArchiveEncrypted = Yii::$app->zipper->open('/tmp/archive.zip', '7zip', 'password12345');

$zipArchive->extract('/tmp/extracted/');

When you configure zipper component with optional properties 'type' and 'password', they will be used as default fourth and fifth parameters in create method, and as default second and third parameters in open method. If you use parameters in this methods obviously, they will overwrite properties from the config. You can leave out properties in the config and the parameters in the methods at all - in this case Zipper will trying understand which adapter to use, but it doesn't work with 7zip archive., (*12)

Both this methods return Archive object. You can find the details about how to use this object and other information in documentation of ZippyExt libruary., (*13)

Requirements

  • For zip type Zipper try to use console command zip or php zip extension, so one of them is required on server for zipping.
  • For tar, tar.gz, tar.bz2 Zipper try to use GNU tar and BSD tar, so one ofo them is required on server for these ways of arching.
  • For zipping by 7zip, the 7za utiliy is required on server.

Установка

ΠŸΡ€Π΅Π΄ΠΏΠΎΡ‡Ρ‚ΠΈΡ‚Π΅Π»ΡŒΠ½Ρ‹ΠΌ способом установки являСтся ΠΏΡ€ΠΈ ΠΏΠΎΠΌΠΎΡ‰ΠΈ composer., (*14)

Π›ΠΈΠ±ΠΎ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ ΠΈΠ· консоли, (*15)

php composer.phar require --prefer-dist victor78/yii2-zipper:"~0.0.4"

Π»ΠΈΠ±ΠΎ Π²ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ΠΌ Π² composer.json Π² ΡΠ΅ΠΊΡ†ΠΈΡŽ require., (*16)

"victor78/yii2-zipper": "~0.0.4"

Настройка

'type' ΠΈ 'password' - ΠΎΠΏΡ†ΠΈΠΎΠ½Π°Π»ΡŒΠ½Ρ‹., (*17)

return [
    //....
    'components' => [
        'zipper' => [
            'class' => 'Victor78\Zipper\Zipper', //required
            'type' => '7zip', //ΠΈΠ»ΠΈ: 'zip' (ΠΏΠΎ ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ), 'tar', 'tar.gz', 'tar.bz2'
            'password' => 'password12345', //ΠΎΠΏΡ†ΠΈΠΎΠ½Π°Π»ΡŒΠ½ΠΎ, Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ ΠΏΡ€ΠΈ Ρ‚ΠΈΠΏΠ΅ 7zip
        ],
    ]
];

Как ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ

Для создания Π°Ρ€Ρ…ΠΈΠ²Π°:, (*18)

//files to archive
$files = [
  '/path/to/file1',
  '/path/to/file2',
];
//ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ tar Π°Ρ€Ρ…ΠΈΠ²
$tarArchive = Yii::$app->zipper->create('/tmp/archive.tar', $files, true, 'tar');

//ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ zip Π°Ρ€Ρ…ΠΈΠ² с ΠΏΠ°Ρ€ΠΎΠ»Π΅ΠΌ ΠΏΡ€ΠΈ ΠΏΠΎΠΌΠΎΡ‰ΠΈ 7zip  
$sevenZipArchive = Yii::$app->zipper->create('/tmp/archive.zip', $files, true, '7zip', 'password12345');
//ΠΈΠ»ΠΈ, Ссли Π²Ρ‹ настроили ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ Zipper ΠΊΠ°ΠΊ Π² ΠΏΡ€ΠΈΠΌΠ΅Ρ€Π΅ Π²Ρ‹ΡˆΠ΅:
$sevenZipArchive = Yii::$app->zipper->create('/tmp/archive.zip', $files);


$zipArchive = Yii::$app->zipper->create('/tmp/archive.zip', $files, true, 'zip'); 

ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΡŒ ΠΈ Ρ€Π°ΡΠΏΠ°ΠΊΠΎΠ²Π°Ρ‚ΡŒ Π°Ρ€Ρ…ΠΈΠ²:, (*19)

$zipArchive = Yii::$app->zipper->open('/tmp/archive.zip', 'zip');
$tarArchive = Yii::$app->zipper->open('/tmp/archive.tar', 'tar');
$sevenZipArchive = Yii::$app->zipper->open('/tmp/archive.zip', '7zip');
//ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚ΡŒ Π·Π°ΠΏΠ°Ρ€ΠΎΠ»Π΅Π½Π½Ρ‹ΠΉ zip созданный ΠΏΡ€ΠΈ ΠΏΠΎΠΌΠΎΡ‰ΠΈ 7zip 
$sevenZipArchiveEncrypted = Yii::$app->zipper->open('/tmp/archive.zip', '7zip', 'password12345');

$zipArchive->extract('/tmp/extracted/');

Если Π²Ρ‹ настроили ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ Zipper с ΠΎΠΏΡ†ΠΈΠΎΠ½Π°Π»ΡŒΠ½Ρ‹ΠΌΠΈ свойствами 'type' ΠΈ 'password', ΠΎΠ½ΠΈ Π±ΡƒΠ΄ΡƒΡ‚ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Π½Ρ‹ ΠΊΠ°ΠΊ Π΄Π΅Ρ„ΠΎΠ»Ρ‚Π½Ρ‹Π΅ Ρ‡Π΅Ρ‚Π²Π΅Ρ€Ρ‚Ρ‹ΠΉ ΠΈ пятый ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ с ΠΌΠ΅Ρ‚ΠΎΠ΄Π΅ create ΠΈ Π²Ρ‚ΠΎΡ€ΠΎΠΉ ΠΈ Ρ‚Ρ€Π΅Ρ‚ΠΈΠΉ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ Π² ΠΌΠ΅Ρ‚ΠΎΠ΄Π΅ open. Если эти ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ Π² этих ΠΌΠ΅Ρ‚ΠΎΠ΄Π°Ρ… ΡƒΠΊΠ°Π·Ρ‹Π²Π°ΡŽΡ‚ΡΡ явно, Ρ‚ΠΎ ΠΎΠ½ΠΈ ΠΏΠ΅Ρ€Π΅ΠΏΠΈΡΡ‹Π²Π°ΡŽΡ‚ свойства ΠΈΠ· ΠΊΠΎΠ½Ρ„ΠΈΠ³Π°. Π’Ρ‹ ΠΌΠΎΠΆΠ΅Ρ‚Π΅ ΠΎΠΏΡƒΡΡ‚ΠΈΡ‚ΡŒ свойства ΠΈΠ· ΠΊΠΎΠ½Ρ„ΠΈΠ³Π° ΠΈ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Ρ‹ Π² ΠΌΠ΅Ρ‚ΠΎΠ΄Π°Ρ… Π²ΠΎΠΎΠ±Ρ‰Π΅ - Π² Ρ‚Π°ΠΊΠΎΠΌ случаС Zipper попытаСтся ΡΠ°ΠΌΠΎΡΡ‚ΠΎΡΡ‚Π΅Π»ΡŒΠ½ΠΎ ΠΏΠΎΠ½ΡΡ‚ΡŒ ΠΊΠ°ΠΊΠΎΠΉ ΠΈΠΌΠ΅Π½Π½ΠΎ Π°Π΄Π°ΠΏΡ‚Π΅Ρ€ ΠΊΠ°ΠΊΠΎΠ³ΠΎ Π°Ρ€Ρ…ΠΈΠ²Π°Ρ‚ΠΎΡ€Π° ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ, Π½ΠΎ это Ρ‚ΠΎΡ‡Π½ΠΎ Π½Π΅ Π±ΡƒΠ΄Π΅Ρ‚ Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π² случаС zip Π°Ρ€Ρ…ΠΈΠ²Π°, созданного ΠΏΡ€ΠΈ ΠΏΠΎΠΌΠΎΡ‰ΠΈ 7zip., (*20)

Оба ΠΌΠ΅Ρ‚ΠΎΠ΄Π° Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°ΡŽΡ‚ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ Archive. Π’Ρ‹ ΠΌΠΎΠΆΠ΅Ρ‚Π΅ Π½Π°ΠΉΡ‚ΠΈ Π΄Π΅Ρ‚Π°Π»ΠΈ ΠΎ Ρ‚ΠΎΠΌ, ΠΊΠ°ΠΊ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ Π΄Π°Π½Π½Ρ‹ΠΉ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ ΠΈ Π΄Ρ€ΡƒΠ³ΡƒΡŽ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡŽ Π² Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π°Ρ†ΠΈΠΈ ΠΊ Π±ΠΈΠ±Π»ΠΎΡ‚Π΅ΠΊΠ΅ ZippyExt., (*21)

ВрСбования

  • Для архивирования Π² чистый zip ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠ΅Ρ‚ΡΡ ΡƒΡ‚ΠΈΠ»ΠΈΡ‚Π° zip ΠΈΠ»ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠ΅ PHP для zip, Ρ‚Π°ΠΊ Ρ‡Ρ‚ΠΎ ΠΈΠ»ΠΈ ΡƒΡ‚ΠΈΠ»ΠΈΡ‚Π°, ΠΈΠ»ΠΈ Ρ€Π°ΡΡˆΠΈΡ€Π΅Π½ΠΈΠ΅ Π΄ΠΎΠ»ΠΆΠ½Ρ‹ Π±Ρ‹Ρ‚ΡŒ установлСны Π½Π° сСрвСрС для ΡƒΠΏΠ°Π²ΠΊΠΈ ΠΈ Ρ€Π°Π·ΡƒΠΏΠ°ΠΊΠΎΠ²ΠΊΠΈ zip.
  • Для tar, tar.gz, tar.bz2 Zipper пытаСтся ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚ΡŒ GNU tar ΠΈΠ»ΠΈ BSD tar, ΠΎΠ΄ΠΈΠ½ ΠΈΠ· Π½ΠΈΡ… Π΄ΠΎΠ»ΠΆΠ΅Π½ Π±Ρ‹Ρ‚ΡŒ установлСн Π½Π° сСрвСрС для этих Ρ‚ΠΈΠΏΠΎΠ² Π°Ρ€Ρ…ΠΈΠ²ΠΎΠ².
  • Для ΡƒΠΏΠ°ΠΊΠΎΠ²ΠΊΠΈ/Ρ€Π°Π·ΡƒΠΏΠ°ΠΊΠΎΠ²ΠΊΠΈ zip ΠΏΡ€ΠΈ ΠΏΠΎΠΌΠΎΡ‰ΠΈ 7zip, Π½Π° сСрвСрС Π΄ΠΎΠ»ΠΆΠ° Π±Ρ‹Ρ‚ΡŒ установлСна ΡƒΡ‚ΠΈΠ»ΠΈΡ‚Π° 7za.

The Versions

02/05 2018

dev-master

9999999-dev

Yii2-Zipper is archiving component for Yii2.

  Sources   Download

MIT

The Requires

 

component yii2 zip archive tar archiver zippy zipper victor78

01/05 2018

0.0.4

0.0.4.0

Yii2-Zipper is archiving component for Yii2.

  Sources   Download

MIT

The Requires

 

component yii2 zip archive tar archiver zippy zipper victor78

21/04 2018

0.0.2

0.0.2.0

Yii2-Zipper is archiving component for Yii2.

  Sources   Download

MIT

The Requires

 

component yii2 zip archive tar archiver zippy zipper victor78

20/04 2018

0.0.1

0.0.1.0

Yii2-Zipper is archiving component for Yii2.

  Sources   Download

MIT

The Requires

 

component yii2 zip archive tar archiver zippy zipper victor78