Download the PHP package radionovel/php-zip without Composer

On this page you can find all versions of the php package radionovel/php-zip. 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 php-zip

PhpZip

PhpZip is a php-library for extended work with ZIP-archives.

Russian Documentation

Table of contents

Features

Requirements

Installation

composer require nelexa/zip

Latest stable version: Latest Stable Version

Examples

Other examples can be found in the tests/ folder

Glossary

Zip Entry - file or folder in a ZIP-archive. Each entry in the archive has certain properties, for example: file name, compression method, encryption method, file size before compression, file size after compression, CRC32 and others.

Documentation:

Overview of methods of the class \PhpZip\ZipFile

Creation/Opening of ZIP-archive

ZipFile::__construct - initializes the ZIP archive.

ZipFile::openFile - opens a zip-archive from a file.

ZipFile::openFromString - opens a zip-archive from a string.

ZipFile::openFromStream - opens a zip-archive from the stream.

Reading entries from the archive

ZipFile::count - returns the number of entries in the archive.

ZipFile::getListFiles - returns list of archive files.

ZipFile::getEntryContent - returns the entry contents using its name.

ZipFile::hasEntry - checks if there is an entry in the archive.

ZipFile::isDirectory - checks that the entry in the archive is a directory.

ZipFile::extractTo - extract the archive contents. The directory must exist.

Extract some files to the directory. The directory must exist.

Iterating entries

ZipFile is an iterator. Can iterate all the entries in the foreach loop.

Can iterate through the Iterator.

Getting information about entries

ZipFile::getArchiveComment - returns the Zip archive comment.

ZipFile::getEntryComment - returns the comment of an entry using the entry name.

ZipFile::getEntryInfo - returns detailed information about the entry in the archive

ZipFile::getAllInfo - returns detailed information about all entries in the archive.

Adding entries to the archive

All methods of adding entries to a ZIP archive allow you to specify a method for compressing content.

The following methods of compression are available:

ZipFile::addFile - adds a file to a ZIP archive from the given path.

ZipFile::addSplFile" - adds a \SplFileInfo to a ZIP archive.

ZipFile::addFromFinder" - adds files from the Symfony\Component\Finder\Finder to a ZIP archive. https://symfony.com/doc/current/components/finder.html

ZipFile::addFromString - adds a file to a ZIP archive using its contents.

ZipFile::addFromStream - adds a entry from the stream to the ZIP archive.

ZipFile::addEmptyDir - add a new directory.

ZipFile::addAll - adds all entries from an array.

ZipFile::addDir - adds files to the archive from the directory on the specified path without subdirectories.

ZipFile::addDirRecursive - adds files to the archive from the directory on the specified path with subdirectories.

ZipFile::addFilesFromIterator - adds files from the iterator of directories.

Example with some files ignoring:

ZipFile::addFilesFromGlob - adds files from a directory by glob pattern without subdirectories.

ZipFile::addFilesFromGlobRecursive - adds files from a directory by glob pattern with subdirectories.

ZipFile::addFilesFromRegex - adds files from a directory by PCRE pattern without subdirectories.

ZipFile::addFilesFromRegexRecursive - adds files from a directory by PCRE pattern with subdirectories.

Deleting entries from the archive

ZipFile::deleteFromName - deletes an entry in the archive using its name.

ZipFile::deleteFromGlob - deletes a entries in the archive using glob pattern.

ZipFile::deleteFromRegex - deletes a entries in the archive using PCRE pattern.

ZipFile::deleteAll - deletes all entries in the ZIP archive.

Working with entries and archive

ZipFile::rename - renames an entry defined by its name.

ZipFile::setCompressionLevel - set the compression level for all files in the archive.

Note that this method does not apply to entries that are added after this method is run.

By default, the compression level is 5 (\PhpZip\Constants\ZipCompressionLevel::NORMAL) or the compression level specified in the archive for Deflate compression.

The values range from 1 (\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST) to 9 (\PhpZip\Constants\ZipCompressionLevel::MAXIMUM) are supported. The higher the number, the better and longer the compression.

ZipFile::setCompressionLevelEntry - sets the compression level for the entry by its name.

The values range from 1 (\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST) to 9 (\PhpZip\Constants\ZipCompressionLevel::MAXIMUM) are supported. The higher the number, the better and longer the compression.

ZipFile::setCompressionMethodEntry - sets the compression method for the entry by its name.

The following compression methods are available:

ZipFile::setArchiveComment - set the comment of a ZIP archive.

ZipFile::setEntryComment - set the comment of an entry defined by its name.

ZipFile::matcher - selecting entries in the archive to perform operations on them.

Selecting files from the archive one at a time:

Select multiple files in the archive:

Selecting files by regular expression:

Select all files in the archive:

count() - gets the number of selected entries:

getMatches() - returns a list of selected entries:

invoke() - invoke a callable function on selected entries:

Functions for working on the selected entries:

Working with passwords

Implemented support for encryption methods:

ZipFile::setReadPassword - set the password for the open archive.

Setting a password is not required for adding new entries or deleting existing ones, but if you want to extract the content or change the method / compression level, the encryption method, or change the password, in this case the password must be specified.

ZipFile::setReadPasswordEntry - gets a password for reading of an entry defined by its name.

ZipFile::setPassword - sets a new password for all files in the archive.

Note that this method does not apply to entries that are added after this method is run.

You can set the encryption method:

ZipFile::setPasswordEntry - sets a new password of an entry defined by its name.

You can set the encryption method:

ZipFile::disableEncryption - disable encryption for all entries that are already in the archive.

Note that this method does not apply to entries that are added after this method is run.

ZipFile::disableEncryptionEntry - disable encryption of an entry defined by its name.

zipalign

ZipFile::setZipAlign - sets the alignment of the archive to optimize APK files (Android packages).

This method adds padding to unencrypted and not compressed entries, to optimize memory consumption in the Android system. It is recommended to use for APK files. The file may grow slightly.

This method is an alternative to executing the zipalign -f -v 4 filename.zip.

More details can be found on the link.

Undo changes

ZipFile::unchangeAll - undo all changes done in the archive.

ZipFile::unchangeArchiveComment - undo changes to the archive comment.

ZipFile::unchangeEntry - undo changes of an entry defined by its name.

Saving a file or output to a browser

ZipFile::saveAsFile - saves the archive to a file.

ZipFile::saveAsStream - writes the archive to the stream.

ZipFile::outputAsString - outputs a ZIP-archive as string.

ZipFile::outputAsAttachment - outputs a ZIP-archive to the browser.

You can set the Mime-Type:

ZipFile::outputAsResponse - outputs a ZIP-archive as PSR-7 Response.

The output method can be used in any PSR-7 compatible framework.

You can set the Mime-Type:

ZipFile::rewrite - save changes and re-open the changed archive.

Closing the archive

ZipFile::close - close the archive.

Running the tests

Install the dependencies for the development:

Run the tests:

Changelog

Changes are documented in the releases page.

Upgrade

Upgrade version 2 to version 3.0

Update the major version in the file composer.json to ^3.0.

Then install updates using Composer:

Update your code to work with the new version:


All versions of php-zip with dependencies

PHP Build Version
Package Version
Requires php Version ^5.5.9 || ^7.0
ext-zlib Version *
psr/http-message Version ^1.0
paragonie/random_compat Version *
symfony/finder Version ^3.0|^4.0|^5.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 radionovel/php-zip contains the following files

Loading the files please wait ....