Download the PHP package lyhiving/zip without Composer

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

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

Packagist Version Packagist Downloads Code Coverage Build Status License <<<<<<< HEAD

=======

74ef59704efd11eb19fe192d1a16772839230f2a

Versions & Dependencies

Version PHP Documentation
^4.0 (master) ^7.4|^8.0 current
^3.0 ^5.5|^7.0 Docs v3.3

Versions & Dependencies

Version PHP Documentation
^4.0 (master) ^7.4|^8.0 current
^3.0 ^5.5|^7.0 Docs v3.3

Table of contents

Features

Requirements

Installation

<<<<<<< HEAD composer require lyhiving/zip

composer require nelexa/zip

74ef59704efd11eb19fe192d1a16772839230f2a

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.

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 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.

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::outputAsPsr7Response

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::outputAsSymfonyResponse

Outputs a ZIP-archive as Symfony Response.

The output method can be used in Symfony framework.

You can set the Mime-Type:

Example use in Symfony Controller:

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 3 to version 4

Update the major version in the file composer.json 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 file composer.json 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 *
symfony/finder Version *
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 lyhiving/zip contains the following files

Loading the files please wait ....