Justin
Justin

Reputation: 45420

Unzip an archive in memory in PHP

Is possible to unzip an archive in PHP in memory, i.e. without writing to disk? I am using curl to get the .zip file from GitHub, and want to extract it without dealing with disk permissions.

 $zip_file = Curl::get_request("https://github.com/user/repo/archive/v1.0.zip");

Upvotes: 1

Views: 3151

Answers (1)

Bob Jansen
Bob Jansen

Reputation: 89

Have a look at the ZIP functions http://php.net/manual/en/book.zip.php

You can access a ZIP file with the zip_open and zip_read functions. You can also access files in a ZIP with the zip:// protocol

file_get_contents('zip://test.zip#test.txt'); 

Upvotes: 1

Related Questions