2017 © Pedro PelĂĄez
 

fuel-package fuel-zip

Zip file manager

image

valdeirpsr/fuel-zip

Zip file manager

  • Monday, April 25, 2016
  • by valdeirpsr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Fuel Zip package

Install

Via Composer, (*1)

``` json { "require": { "valdeirpsr/fuel-zip": "dev-master" } }, (*2)


Via Composer (Command Line) ``` shell composer require valdeirpsr/fuel-zip

Configuration

``` php return [ 'default' => [ 'comment' => 'Created ' . date('c'), 'password' => null, 'save_to' => null, 'password_generator' => [ 'enabled' => false, 'length' => 8, 'type' => 'alnum' ] ] ];, (*3)


## Translate ``` php return [ 'error_0' => 'No error', 'error_1' => 'Multi-disk zip archives not supported', 'error_2' => 'Renaming temporary file failed', 'error_3' => 'Closing zip archive failed', 'error_4' => 'Seek error', 'error_5' => 'Read error', 'error_6' => 'Write error', 'error_7' => 'CRC error', 'error_8' => 'Containing zip archive was closed', 'error_9' => 'No such file', 'error_10' => 'File already exists', 'error_11' => 'Can\'t open file', 'error_12' => 'Failure to create temporary file', 'error_13' => 'Zlib error', 'error_14' => 'Malloc failure', 'error_15' => 'Entry has been changed', 'error_16' => 'Compression method not supported', 'error_17' => 'Premature EOF', 'error_18' => 'Invalid argument', 'error_19' => 'Not a zip archive', 'error_20' => 'Internal error', 'error_21' => 'Zip archive inconsistent', 'error_22' => 'Can\'t remove file', 'error_23' => 'Entry has been deleted', 'error_should_be_number' => 'A non well formed numeric value encountered', 'error_method_unsupported' => 'Method \':method\' unsupported', 'error_opsys_unsupported' => 'Operaciocnal System \':opsys\' unsupported', 'error_flags_unsupported' => 'Flag unsupported', 'error_name_required' => 'New name is required!', ];

Usage

``` php Zip\Zip::forge(); Zip\Zip::open("teste.zip", Zip\Zip::CREATE); Zip\Zip::addEmptyDir("new_folder"); Zip\Zip::addFile("index.php"); Zip\Zip::addFile("favicon.ico"); Zip\Zip::addDir(DOCROOT."files"); Zip\Zip::save();, (*4)

// Or $zip = new Zip\Zip; $zip->open("teste2.zip", Zip\Zip::CREATE); $zip->addEmptyDir("new_folder"); $zip->addFile("index.php"); $zip->addFile("favicon.ico"); $zip->addDir(DOCROOT."files"); $zip->save();, (*5)



## Creating directory in the zip file ``` php $zip->createDir([ 'one', 'two' ]); $zip->createDir('three');

Creating file in the zip file

``` php $zip->createFile([ 'pass.pwd' => 'File content', 'error_log.txt' => 'No error' ]);, (*6)

$zip->createFile('music.txt', 'Na alegria, na tristeza, sempre lado a lado Com carinho ensinou meus primeiro passos Mais uma guerreira de pele escura, sofredora Tenho muito orgulho de minha coroa Sua garra, seu jeito simples de ser Essas qualidades sĂŁo exemplo pra viver Seus conselhos foram forças pra nunca desistir Muito obrigado por vocĂȘ existir, (*7)

Link: http://www.vagalume.com.br/509-e/rainha-do-lar.html');, (*8)


## Deleting files ``` php // By Index $zip->delete(1); // By Filename $zip->delete([ 'music.txt', 'file2.txt ]);

Renaming files

``` php // Old Name, New Name $zip->rename('error_log.txt', 'no_error.txt');, (*9)

$zip->rename([ 'music.txt' => 'Rainha do Lar - 509-E.txt' // Old Name => New Name ]);, (*10)


## Describing files ``` php // Index, Description $zip->setComment(1, 'First comment'); $zip->setComment([ 'Rainha do Lar - 509-E.txt' => 'Brazilian rap' //Filename => Description ]); // Comment the zip $zip->setArchiveComment("new comment");

Adding directories

``` php $zip->addDir(DOCROOT."files/music");, (*11)

// Or $zip->addDir([ DOCROOT."files/music", DOCROOT."files/photo", DOCROOT."files/videos" ]);, (*12)

// Or with filter $zip->addDir([ DOCROOT."files/music", DOCROOT."files/photo", DOCROOT."files/videos" ], 0, [ '!^.', // no hidden files/dirs '!^private' => 'dir', // no private dirs '.png$' => 'file', // only get png's '.css$' => 'file', // or css files '!^_', // exclude everything that starts with an underscore. ]);, (*13)


## Adding files ``` php $zip->addFile(DOCROOT."music1.mp3"); $zip->addFile(DOCROOT."music2.mp3"); $zip->addFile(DOCROOT."music3.mp3"); // Or $zip->addFile([ DOCROOT."music1.mp3", DOCROOT."music2.mp3" => "new_dir", DOCROOT."music3.mp3" => "new_dir/music" ]);

Set the compression

``` php $zip->setCompression("my_file.txt", Zip\Zip::CM_DEFLATE);, (*14)


## List of all the zip files ``` php // All files $zip->listFiles(); // Filter files in the directory music/ $zip->listFiles("music/"); // Filter files in the directory music/ and image/ $zip->listFiles([ "music", "image" ]);

Open File

``` php $zip->open("psr.zip", Zip\Zip::CREATE);, (*15)


## Save file changes ``` php $zip->save();

extract

php $zip->extract(DOCROOT."extracted");, (*16)

Credits

License

The MIT License (MIT). Please see License File for more information., (*17)

The Versions

25/04 2016

dev-master

9999999-dev http://www.valdeirsantana.com.br

Zip file manager

  Sources   Download

MIT

The Requires

 

by Valdeir Santana

fuelphp zip compress ziparchive fuel fuel-php zip file

25/04 2016

0.0.1

0.0.1.0 http://www.valdeirsantana.com.br

Zip file manager

  Sources   Download

MIT

The Requires

 

by Valdeir Santana

fuelphp zip compress ziparchive fuel fuel-php zip file