`PhpZip`
========
`PhpZip` is a php-library for extended work with ZIP-archives.
[![Build Status](https://travis-ci.org/Ne-Lexa/php-zip.svg?branch=master)](https://travis-ci.org/Ne-Lexa/php-zip)
[![Latest Stable Version](https://poser.pugx.org/nelexa/zip/v/stable)](https://packagist.org/packages/nelexa/zip)
[![Total Downloads](https://poser.pugx.org/nelexa/zip/downloads)](https://packagist.org/packages/nelexa/zip)
[![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D%205.5-8892BF.svg)](https://php.net/)
[![License](https://poser.pugx.org/nelexa/zip/license)](https://packagist.org/packages/nelexa/zip)
[Russian Documentation](README.RU.md)
Table of contents
-----------------
- [Features](#Features)
- [Requirements](#Requirements)
- [Installation](#Installation)
- [Examples](#Examples)
- [Glossary](#Glossary)
- [Documentation](#Documentation)
+ [Overview of methods of the class `\PhpZip\ZipFile`](#Documentation-Overview)
+ [Creation/Opening of ZIP-archive](#Documentation-Open-Zip-Archive)
+ [Reading entries from the archive](#Documentation-Open-Zip-Entries)
+ [Iterating entries](#Documentation-Zip-Iterate)
+ [Getting information about entries](#Documentation-Zip-Info)
+ [Adding entries to the archive](#Documentation-Add-Zip-Entries)
+ [Deleting entries from the archive](#Documentation-Remove-Zip-Entries)
+ [Working with entries and archive](#Documentation-Entries)
+ [Working with passwords](#Documentation-Password)
+ [zipalign - alignment tool for Android (APK) files](#Documentation-ZipAlign-Usage)
+ [Undo changes](#Documentation-Unchanged)
+ [Saving a file or output to a browser](#Documentation-Save-Or-Output-Entries)
+ [Closing the archive](#Documentation-Close-Zip-Archive)
- [Running the tests](#Running-Tests)
- [Changelog](#Changelog)
- [Upgrade](#Upgrade)
+ [Upgrade version 2 to version 3.0](#Upgrade-v2-to-v3)
### <a name="Features"></a> Features
- Opening and unzipping zip files.
- Creating ZIP-archives.
- Modifying ZIP archives.
- Pure php (not require extension `php-zip` and class `\ZipArchive`).
- It supports saving the archive to a file, outputting the archive to the browser, or outputting it as a string without saving it to a file.
- Archival comments and comments of individual entry are supported.
- Get information about each entry in the archive.
- Only the following compression methods are supported:
+ No compressed (Stored).
+ Deflate compression.
+ BZIP2 compression with the extension `php-bz2`.
- Support for `ZIP64` (file size is more than 4 GB or the number of entries in the archive is more than 65535).
- Built-in support for aligning the archive to optimize Android packages (APK) [`zipalign`](https://developer.android.com/studio/command-line/zipalign.html).
- Working with passwords for PHP 5.5
> **Attention!**
>
> For 32-bit systems, the `Traditional PKWARE Encryption (ZipCrypto)` encryption method is not currently supported.
> Use the encryption method `WinZIP AES Encryption`, whenever possible.
+ Set the password to read the archive for all entries or only for some.
+ Change the password for the archive, including for individual entries.
+ Delete the archive password for all or individual entries.
+ Set the password and/or the encryption method, both for all, and for individual entries in the archive.
+ Set different passwords and encryption methods for different entries.
+ Delete the password for all or some entries.
+ Support `Traditional PKWARE Encryption (ZipCrypto)` and `WinZIP AES Encryption` encryption methods.
+ Set the encryption method for all or individual entries in the archive.
### <a name="Requirements"></a> Requirements
- `PHP` >= 5.5 (preferably 64-bit).
- Optional php-extension `bzip2` for BZIP2 compression.
- Optional php-extension `openssl` or `mcrypt` for `WinZip Aes Encryption` support.
### <a name="Installation"></a> Installation
`composer require nelexa/zip`
Latest stable version: [![Latest Stable Version](https://poser.pugx.org/nelexa/zip/v/stable)](https://packagist.org/packages/nelexa/zip)
### <a name="Examples"></a> Examples
```php
// create new archive
$zipFile = new \PhpZip\ZipFile();
try{
$zipFile
->addFromString("zip/entry/filename", "Is file content") // add an entry from the string
->addFile("/path/to/file", "data/tofile") // add an entry from the file
->addDir(__DIR__, "to/path/") // add files from the directory
->saveAsFile($outputFilename) // save the archive to a file
->close(); // close archive
// open archive, extract, add files, set password and output to browser.
$zipFile
->openFile($outputFilename) // open archive from file
->extractTo($outputDirExtract) // extract files to the specified directory
->deleteFromRegex('~^\.~') // delete all hidden (Unix) files
->addFromString('dir/file.txt', 'Test file') // add a new entry from the string
->setPassword('password') // set password for all entries
->outputAsAttachment('library.jar'); // output to the browser without saving to a file
}
catch(\PhpZip\Exception\ZipException $e){
// handle exception
}
finally{
$zipFile->close();
}
```
Other examples can be found in the `tests/` folder
### <a name="Glossary"></a> 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.
### <a name="Documentation"></a> Documentation:
#### <a name="Documentation-Overview"></a> Overview of methods of the class `\PhpZip\ZipFile`
- [ZipFile::__construct](#Documentation-ZipFile-__construct) - initializes the ZIP archive.
- [ZipFile::addAll](#Documentation-ZipFile-addAll) - adds all entries from an array.
- [ZipFile::addDir](#Documentation-ZipFile-addDir) - adds files to the archive from the directory on the specified path without subdirectories.
- [ZipFile::addDirRecursive](#Documentation-ZipFile-addDirRecursive) - adds files to the archive from the directory on the specified path with subdirectories.
- [ZipFile::addEmptyDir](#Documentation-ZipFile-addEmptyDir) - add a new directory.
- [ZipFile::addFile](#Documentation-ZipFile-addFile) - adds a file to a ZIP archive from the given path.
- [ZipFile::addFilesFromIterator](#Documentation-ZipFile-addFilesFromIterator) - adds files from the iterator of directories.
- [ZipFile::addFilesFromGlob](#Documentation-ZipFile-addFilesFromGlob) - adds files from a directory by glob pattern without subdirectories.
- [ZipFile::addFilesFromGlobRecursive](#Documentation-ZipFile-addFilesFromGlobRecursive) - adds files from a directory by glob pattern with subdirectories.
- [ZipFile::addFilesFromRegex](#Documentation-ZipFile-addFilesFromRegex) - adds files from a directory by PCRE pattern without subdirectories.
- [ZipFile::addFilesFromRegexRecursive](#Documentation-ZipFile-addFilesFromRegexRecursive) - adds files from a directory by PCRE pattern with subdirectories.
- [ZipFile::addFromStream](#Documentation-ZipFile-addFromStream) - adds a entry from the stream to the ZIP archive.
- [ZipFile::addFromString](#Documentation-ZipFile-addFromString) - adds a file to a ZIP archive using its contents.
- [ZipFile::close](#Documentation-ZipFile-close) - close the archive.
- [ZipFile::count](#Documentation-ZipFile-count) - returns the number of entries in the archive.
- [ZipFile::deleteFromName](#Documentation-ZipFile-deleteFromName) - deletes an entry in the archive using its name.
- [ZipFile::deleteFromGlob](#Documentation-ZipFile-deleteFromGlob) - deletes a entries in the archive using glob pattern.
- [ZipFile::deleteFromRegex](#Documentation-ZipFile-deleteFromRegex) - deletes a entries in the archive using PCRE pattern.
- [ZipFile::deleteAl
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
在线教育直播系统功能模块 (6714个子文件)
random_compat.phar.pubkey.asc 499B
crond_windows.bat 951B
UniCNS-UTF8-H.bcmap 52KB
UniCNS-UTF32-H.bcmap 51KB
UniCNS-UTF16-H.bcmap 49KB
UniCNS-UCS2-H.bcmap 47KB
UniGB-UTF8-H.bcmap 46KB
UniGB-UTF32-H.bcmap 45KB
UniGB-UTF16-H.bcmap 43KB
UniGB-UCS2-H.bcmap 42KB
UniJIS2004-UTF8-H.bcmap 41KB
UniJIS-UTF8-H.bcmap 41KB
Adobe-CNS1-UCS2.bcmap 40KB
Adobe-Japan1-UCS2.bcmap 40KB
UniJIS2004-UTF32-H.bcmap 40KB
UniJISX02132004-UTF32-H.bcmap 40KB
UniJIS-UTF32-H.bcmap 40KB
UniJISX0213-UTF32-H.bcmap 40KB
UniJIS2004-UTF16-H.bcmap 39KB
UniJIS-UTF16-H.bcmap 39KB
Adobe-GB1-UCS2.bcmap 33KB
UniKS-UTF8-H.bcmap 27KB
UniKS-UTF32-H.bcmap 26KB
UniKS-UTF16-H.bcmap 26KB
UniKS-UCS2-H.bcmap 25KB
UniJIS-UCS2-H.bcmap 25KB
Adobe-Korea1-UCS2.bcmap 23KB
GBK2K-H.bcmap 19KB
KSC-Johab-H.bcmap 16KB
GBK-EUC-H.bcmap 14KB
GBKp-EUC-H.bcmap 14KB
GBTpc-EUC-H.bcmap 7KB
GBT-EUC-H.bcmap 7KB
GBT-H.bcmap 7KB
HKscs-B5-H.bcmap 4KB
ETHK-B5-H.bcmap 4KB
KSCms-UHC-HW-H.bcmap 3KB
KSCms-UHC-H.bcmap 3KB
NWP-H.bcmap 3KB
HKdla-B5-H.bcmap 3KB
78ms-RKSJ-H.bcmap 3KB
Ext-RKSJ-H.bcmap 2KB
Ext-H.bcmap 2KB
Add-H.bcmap 2KB
HKdlb-B5-H.bcmap 2KB
Add-RKSJ-H.bcmap 2KB
78-EUC-H.bcmap 2KB
78-RKSJ-H.bcmap 2KB
78-H.bcmap 2KB
HKgccs-B5-H.bcmap 2KB
HKm471-B5-H.bcmap 2KB
KSCpc-EUC-H.bcmap 2KB
CNS-EUC-V.bcmap 2KB
KSC-EUC-H.bcmap 2KB
KSC-H.bcmap 2KB
CNS-EUC-H.bcmap 2KB
HKm314-B5-H.bcmap 2KB
ETen-B5-H.bcmap 1KB
B5pc-H.bcmap 1KB
B5-H.bcmap 1KB
90pv-RKSJ-H.bcmap 982B
83pv-RKSJ-H.bcmap 905B
UniJISPro-UTF8-V.bcmap 726B
90ms-RKSJ-H.bcmap 721B
90msp-RKSJ-H.bcmap 715B
CNS1-H.bcmap 706B
UniJISPro-UCS2-HW-V.bcmap 705B
UniJISPro-UCS2-V.bcmap 689B
UniJISX02132004-UTF32-V.bcmap 688B
UniJISX0213-UTF32-V.bcmap 684B
UniJIS2004-UTF8-V.bcmap 682B
UniJIS2004-UTF32-V.bcmap 681B
UniJIS-UCS2-HW-V.bcmap 680B
UniJIS-UTF8-V.bcmap 678B
UniJIS-UTF32-V.bcmap 677B
UniJIS-UCS2-V.bcmap 664B
UniJIS2004-UTF16-V.bcmap 647B
UniJIS-UTF16-V.bcmap 643B
Adobe-GB1-5.bcmap 625B
Adobe-GB1-4.bcmap 601B
EUC-H.bcmap 578B
GBpc-EUC-H.bcmap 557B
H.bcmap 553B
GB-EUC-H.bcmap 549B
RKSJ-H.bcmap 534B
GB-H.bcmap 528B
CNS2-H.bcmap 504B
Adobe-Japan1-6.bcmap 485B
Adobe-GB1-3.bcmap 470B
Adobe-GB1-2.bcmap 465B
Adobe-Japan1-5.bcmap 430B
Adobe-CNS1-5.bcmap 406B
Adobe-CNS1-6.bcmap 406B
Adobe-CNS1-4.bcmap 405B
Adobe-CNS1-3.bcmap 401B
Adobe-Korea1-2.bcmap 391B
Adobe-Korea1-1.bcmap 386B
Adobe-CNS1-2.bcmap 376B
Adobe-CNS1-1.bcmap 371B
Adobe-Japan1-4.bcmap 337B
共 6714 条
- 1
- 2
- 3
- 4
- 5
- 6
- 68
qq_34087993
- 粉丝: 3
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0