`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)
[![Code Coverage](https://scrutinizer-ci.com/g/Ne-Lexa/php-zip/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Ne-Lexa/php-zip/?branch=master)
[![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::addSplFile](#Documentation-ZipFile-addSplFile) - adds a `\SplFileInfo` to a ZIP archive.
- [ZipFile::addFromFinder](#Documentation-ZipFile-addFromFinder) - adds files from the `Symfony\Component\Finder\Finder` to a ZIP archive.
- [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.
希希分享
- 粉丝: 7112
- 资源: 3860
最新资源
- 基于粒子群算法的电动汽车充电站和光伏最优选址和定容 关键词:选址定容 电动汽车 充电站位置 仿真平台:MATLAB 主要内容:代码主要做的是一个电动汽车充电站和分布式光伏的选址定容问题,提出了
- 伺服送料机,步进电机,伺服电机,程序,三菱,台达,中达一体机,送料机程序,PLC多段数据不同,可任意调节A段B段c段长度,并定长切断 程序能存储5段工件数据,使用调出非常方便 PLC程序有台达ES
- 考虑安全约束及热备用的电力系统机组组合研究 关键词:机组组合 直流潮流 优化调度 参考文档:店主自编文档,模型数据清晰明了 仿真平台:MATLAB+CPLEX gurobi平台 优势:代码具有一定
- 计及源-荷双重不确定性的电厂 微网日前随机优化调度系统 关键词:电厂 微网 随机优化 随机调度 源-荷双重不确定性 电厂调度 参考文档:Virtual power plant mid-ter
- 基于mpc模型预测轨迹跟踪控制,总共包含两套仿真,一套是不加入四轮侧偏角软约束,一套是加入四轮侧偏角的软约束控制,通过carsim与simulink联合仿真发现加入侧偏角软约束在进行轨迹跟踪时,能够通
- 采用下垂控制的孤岛逆变器仿真 名称:droop-controlled-converter-island 软件:Matlab R2016a 控制:下垂控制,闭环电流反馈控制,解耦电压电流环控制,见图1
- 直驱式波浪发电最大功率捕获matlab仿真 电机:直线电机 控制器:PID控制器 策略:基于RLC等效电路模型的最大功率输出 含:使用说明书+教学视频
- 西门子200smart标准程序,西门子程序模板参考,3轴控制程序,含西门子触摸屏程序,详细注释,IO表,电气原理图
- 基于西门子PLC200自动保暖供水系统,系统用于厂区饮用水,区域热水保暖,系统中大多数用于时间进行各个季节,各个时间的控制 供水区域时间的设定 可以实现在每一个阶段按照每一个流程进行不同的运行
- 西门子S7-1200四层电梯模拟程序 电梯WinCC动画程序 西门子参考学习程序 博图15或者以上可以打开 PLC:西门子S7-1200 触摸屏:KTP900 有人会问:为什么是四层电梯参考学习程序
- 整车电子电气正向开发网络架构 , 倘若您是产品经理或者项目经理又或者是技术leader,这个将帮助您梳理在整车电子电气正向开发过程中不同系统的内部架构设计及相互间的关联,涵盖整车控制系统、网联系统、驾
- dsp28335三相逆变程序,可以开环测试
- 含分布式电源的无功补偿(Matlab程序): 1.以无功补偿调节代价为目标函数,不同风光电源渗透率下,优化确定无功补偿装置出力情况(改进灰狼优化算法IGWO) 2.以网损和电压偏差为目标函数,才用分
- 整车控制器 基于MPC和滑模控制算法实现的车辆稳定性控制,建立了横摆角速度、侧向速度、前后质心侧偏角动力学模型作为预测模型,同时考虑车辆的稳定性可通过控制车辆的侧向速度维持在一定范围内保证车辆的稳定性
- COMSOL MATLAB 代码 二维随机裂隙 2维随机裂隙生成 功能:可以实现多组不同方向,不同分布规律的裂隙生成(任意组数都可以) 需要输入的参数有:每组裂隙的迹长范围、分布规律(正态分布o
- 全阶滑模无位置传感器控制仿真模型,有基本的开关函数,有饱和函数,sigmod函数等多种滑模 还有全阶滑模观测器仿真,相比传统滑模观测器消除了额外的低通滤波器,误差更小,效果堪称完美 不仅误差小
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈