stolentine/zip-partial-reader

Client for read one file from zip archive by curl

v0.1.1 2022-12-08 12:54 UTC

This package is auto-updated.

Last update: 2024-06-08 16:37:37 UTC


README

Client for read one file from zip archive by curl.

use Stolentine\ZipPartialReader\ZipPartialReader;

$zip = ZipPartialReader::openUrl('https://example.com/foo.zip');

$path = '/var/www/files/';
$pathName = '/var/www/files/fooBazBar.xml';
$filePathName = 'baz/bar.xml';

foreach ($zip->getFiles() as $file) {
    if (str_starts_with($file->name, $filePathName)) {
        $zip->extractToDir($file, new SplFileInfo($path));
        // or 
        $zip->extractToFile($file, new SplFileInfo($pathName));
    }
}