commando1251 / archive
Simple and smart archive builder
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^7.1.3
This package is auto-updated.
Last update: 2025-03-01 00:24:10 UTC
README
Smart and simple PHP archive builder. You can create an archive, save it to disk or send it to the user. Supports adding files from local disc, URL or string. It allows saving the complex structure as a folder tree. Supports zip and tar archives. To create tar.gz archive please look at the following example.
Requirements
PHP >= 7.1.3, Composer
For zip archives installed zlib
Installing
$ composer require commando1251/archive
Basic Usage
<?php require __DIR__.'/vendor/autoload.php'; use Commando1251\Archive\ArchiveCreator; try { $archive = new ArchiveCreator('test' . time() . '.zip'); $archive->add('/var/www/archive_test/pics/folder1/1.jpg'); $archive->add('/var/www/archive_test/pics/folder1/2.jpg', 'test_folder'); $archive->build(); } catch (Exception $exception) { echo $exception->getMessage(); }
Test folder with files named "pics" located in the examples folder. Place it in document root or other location and edit path to test .jpg files in data arrays. Current path is shown for informational purposes only.
Laravel
To use the package in Laravel environment please do the following steps:
$ composer require commando1251/archive
Set the service provider fully qualified class name in the config.app:
config/app.php
<?php return [ ... 'providers' => [ .... Commando1251\Archive\Laravel\ArchiveServiceProvider::class ] ];
To register facade add following code:
<?php return [ ... 'aliases' => [ .... 'Archive' => Commando1251\Archive\Laravel\Facades\Archive::class ] ];
Please look for Laravel examples
About
Author
Andrey Dobrozhanskiy - andrey.dobrozhanskiy@gmail.com
License
Simple archives builder is licensed under the MIT License - see the LICENSE file for details