xp-framework / zip
ZIP File support for the XP Framework
Installs: 40 735
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.0.0
- xp-forge/compression: ^1.2
- xp-framework/core: ^12.0 | ^11.0 | ^10.0
- xp-framework/math: ^9.0 | ^8.0
Requires (Dev)
- xp-framework/test: ^2.0 | ^1.0
README
Usage (creating a zip file)
use io\archive\zip\{ZipFile, ZipDirEntry, ZipFileEntry}; use io\File; $z= ZipFile::create(new File('dist.zip')); // Add a directory $dir= $z->add(new ZipDirEntry('META-INF')); // Add a file $file= $z->add(new ZipFileEntry($dir, 'version.txt')); $file->out()->write($contents); // Close $z->close();
Usage (reading a zip file)
use io\archive\zip\ZipFile; use io\streams\Streams; use io\File; $z= ZipFile::open(new File('dist.zip')); foreach ($z->entries() as $entry) { if ($entry->isDirectory()) { // Create dir } else { // Extract Streams::readAll($entry->in()); } }