Download the PHP package nelexa/zip without Composer

On this page you can find all versions of the php package nelexa/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?
nelexa/zip
Rate from 1 - 5
Rated 3.00 based on 1 reviews

Informations about the package zip

PhpZip is a PHP library for extended work with ZIP archives.

Packagist Version PHP Version Packagist Downloads Build Status License

Russian Documentation

Supported Versions

Version PHP Status Documentation
^4.0, ^4.1 (master) 7.4, 8.0 - 8.5 Active support current
^3.0 5.5 - 7.x End of life Docs v3.3

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 - a 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 a 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. You can iterate over all entries in a foreach loop.

You can iterate using the Iterator interface.

Getting information about entries

ZipFile::getArchiveComment

Returns the Zip archive comment.

ZipFile::getEntryComment

Returns the comment of an entry using the entry name.

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.

ZipFile::addFromString

Adds a file to a ZIP archive using its contents.

ZipFile::addFromStream

Adds an 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 that ignores some files:

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 entries in the archive using a glob pattern.

ZipFile::deleteFromRegex

Deletes entries in the archive using a PCRE pattern.

ZipFile::deleteAll

Deletes all entries in the ZIP archive.

Working with entries and archive

ZipFile::rename

Renames an entry identified 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.

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

ZipFile::setCompressionLevelEntry

Sets the compression level for the entry by its name.

Supported values range from 1 (\PhpZip\Constants\ZipCompressionLevel::SUPER_FAST) to 9 (\PhpZip\Constants\ZipCompressionLevel::MAXIMUM). 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

Sets the comment of an entry identified by its name.

ZipFile::matcher

Selecting entries in the archive to perform operations on them.

Selecting files from the archive one at a time:

Selecting multiple files in the archive:

Selecting files by regular expression:

Selecting all files in the archive:

count() - gets the number of selected entries:

getMatches() - returns a list of selected entries:

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

Functions for working with the selected entries:

Working with passwords

The following encryption methods are implemented:

ZipFile::setReadPassword

Set the password for the open archive.

Setting a password is not required for adding new entries or deleting existing ones. However, to extract content, or to change the compression level, the encryption method or the password, the password must be specified.

ZipFile::setReadPasswordEntry

Sets a password for reading an entry identified 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 for an entry identified 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

Disables encryption of an entry identified by its name.

Undo changes

ZipFile::unchangeAll

Undo all changes made to the archive.

ZipFile::unchangeArchiveComment

Undo changes to the archive comment.

ZipFile::unchangeEntry

Undo changes to an entry identified 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 a stream.

ZipFile::outputAsString

Outputs a ZIP archive as a string.

ZipFile::outputAsAttachment

Outputs a ZIP archive to the browser.

You can set the MIME type:

ZipFile::outputAsPsr7Response

Outputs a ZIP archive as a PSR-7 Response.

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

You can set the MIME type:

ZipFile::outputAsSymfonyResponse

Outputs a ZIP archive as a Symfony Response.

The output method can be used in the Symfony framework.

You can set the MIME type:

Example of use in a Symfony controller:

ZipFile::rewrite

Save changes and reopen the changed archive.

Closing the archive

ZipFile::close

Close the archive.

Running the tests

Install the development dependencies:

Run the tests:

Changelog

Changes are documented in the releases page.

Upgrade

Upgrade version 3 to version 4

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

Then install updates using Composer:

Update your code to work with the new version: BC

Upgrade version 2 to version 3

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

Then install updates using Composer:

Update your code to work with the new version:


All versions of zip with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
ext-zlib Version *
psr/http-message Version ^1.0 || ^2.0
symfony/finder Version ^5.4 || ^6.0 || ^7.0 || ^8.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 nelexa/zip contains the following files

Loading the files please wait ...