php / php/php-src

in-memory ZipArchive

Open
#11,594 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Extension: zip Feature
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Currently ZipArchive relies on the filesystem, for both opening and extracting files.

Would it be possible to have it work with files (or data) in memory? Or is that a limitation of the underlying zip library?

Below is an example of ZipArchive not being able to open files from a virtual file system (probably because it's a stream).

$vfs = \org\bovigo\vfs\vfsStream::setup();

copy('foo.zip', $vfs->url() . '/foo.zip');

var_dump(file_get_contents($vfs->url() . '/foo.zip')); // file contents appears

$zip = new ZipArchive();
$zip->open($vfs->url() . '/foo.zip');
$zip->extractTo(__DIR__); // Uncaught ValueError: Invalid or uninitialized Zip object
$zip->close();

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ZipArchive open() and extractTo() behavior shown in the vfsStream example, then investigate the underlying zip library's support for streams or in-memory data. Done means ZipArchive can open and extract an archive supplied from a virtual filesystem or memory without relying on ordinary filesystem paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.