https://github.com/xp-framework/zip
ZIP File support for the XP Framework
https://github.com/xp-framework/zip
php7 php8 stream xp-framework zip
Last synced: 28 days ago
JSON representation
ZIP File support for the XP Framework
- Host: GitHub
- URL: https://github.com/xp-framework/zip
- Owner: xp-framework
- Created: 2013-11-10T22:18:54.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-10-05T11:11:42.000Z (8 months ago)
- Last Synced: 2025-04-12T13:05:57.634Z (about 1 month ago)
- Topics: php7, php8, stream, xp-framework, zip
- Language: PHP
- Homepage:
- Size: 3.21 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
README
ZIP File support
================[](https://github.com/xp-framework/zip/actions)
[](https://github.com/xp-framework/core)
[](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[](http://php.net/)
[](http://php.net/)
[](https://packagist.org/packages/xp-framework/zip)Usage (creating a zip file)
---------------------------```php
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)
--------------------------```php
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());
}
}
```