Download the PHP package glucnac/ziparchivemanager without Composer

On this page you can find all versions of the php package glucnac/ziparchivemanager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ziparchivemanager

GlucNAc/ZipArchiveManager

A simple wrapper around PHP's native ZipArchive, to make it easier to work with.

Source Code Download Package PHP Programming Language Read License Build Status Code coverage badge

Installation

Install this package as a dependency using Composer.

Usage

The GlucNAc/ZipArchiveManager provides a more object-oriented interface to work with PHP's native ZipArchive, making it easier to create, extract, and modify zip archives.

Creating a new ZipArchive

To create a new zip archive, you can use the ZipArchiveBuilder class. The ZipArchiveBuilder requires a ZipArchiveManager object to manage the storage of the archive. The ZipArchiveBuilder class provides a fluent interface to add files to the archive.

Now the archive exists at /path/to/storage/archive/test.zip and will have this structure:

This can also be done quickly with the ZipArchiveBuilder::buildWithFiles method:

Customizing the file structure in the archive

By default, the archive structure will mirror the structure of the files. If you want to change the structure of the files in the archive, you can use an associative array where the keys are the paths to the files and the values are the paths to the files in the archive:

Now the archive exists at /path/to/storage/archive/test.zipand will have this structure:

Adding files from a directory

Given the following directory structure:

If you want to create an archive with all the files in the /path/to directory, while keeping the structure of the files in the archive, you can use the ZipArchiveBuilder::addFilesFromPath method:

The ArchivableFileManager::getArchivableFilesFromPath method returns an array of ArchivableFile objects, which implement the ArchivableFileInterface interface, and where the path of the files in the archive will be relative to the path passed to the method (/path/to in this case).

This works because ZipArchiveBuilder::buildWithFiles, ZipArchiveBuilder::addFiles and ZipArchiveBuilder::addFile methods also accept an array of ArchivableFileInterface objects (in addition to file paths).

See the ArchivableFile section for more information about ArchivableFileInterface and ArchivableFile objects.

Keeping the archive open

By default, build methods will close the archive after building it. If you want to keep the archive open, you can pass false as the first argument to the build method:

Adding files to an existing zip archive

To add files to an existing zip archive, you just have to open the archive with the ZipArchiveManager::open method and use methods described in the Creating a new ZipArchive section:

Extracting files from a ZipArchive

To extract files from a zip archive, simply use the ZipArchiveManager::extractFiles method:

ArchivableFile

For this section, let's consider the following directory structure:

You may have noticed that ZipArchiveManager uses the ArchivableFile class to represent files that can be added to a zip archive. More precisely, ZipArchiveManager expects an object that implements the ArchivableFileInterface. This interface defines the methods that an object must implement to be considered an archivable file. The ArchivableFile class provided by this package implements this interface and provides a simple way to work with files that can be added to a zip archive.

You can create your own class that implements this interface, or you can use the ArchivableFile class provided by this package. To do so, you can use the ArchivableFileManager::getArchivableFileFromPath method to get an ArchivableFile object from a file path:

You can also use the ArchivableFileManager::getArchivableFilesFromPath method to get an array of ArchivableFile objects from a directory path:

Internally, the ArchivableFile class uses the SplFileInfo class to represent files. You can also use the SplFileInfoToArchivableFileTransformer class to transform an SplFileInfo object into an ArchivableFile object:

Contributing

Contributions are welcome! To contribute, please familiarize yourself with CONTRIBUTING.md.

Coordinated Disclosure

Keeping user information safe and secure is a top priority, and we welcome the contribution of external security researchers. If you believe you've found a security issue in software that is maintained in this repository, please read SECURITY.md for instructions on submitting a vulnerability report.

Copyright and License

GlucNAc/ZipArchiveManager is copyright © GlucNAc and licensed for use under the terms of the MIT License (MIT). Please see LICENSE for more information.


All versions of ziparchivemanager with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-zip Version *
doctrine/collections Version ^2.0|^3.0
symfony/finder Version ^5.4|^6.0|^7.0
symfony/options-resolver Version ^5.4|^6.0|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package glucnac/ziparchivemanager contains the following files

Loading the files please wait ....