13

I can't find one and I don't know if any of PHP Compression and Archive Extensions will work.

Do you think I could use a compression stream to read data from a 7z file?

UPDATE

  • 7z forums have a lot of requests for a php extension
Elzo Valugi
  • 24,234
  • 13
  • 88
  • 112
  • If there is none, you can still use `exec`to interface with 7zip. – Gordon Oct 08 '10 at 07:42
  • I know but I would prefer to find a solution without exec. – Elzo Valugi Oct 08 '10 at 07:46
  • I considered writing an extension for 7-Zip, but... 7-Zip itself is Windows-only. p7zip, on the other hand, does not support Windows. So it would be difficult to write a portable extension. Then, if I remember correctly, there's the problem with the license being LGPL which is not ideal. Just using the LZMA SDK would be possible (I think it has a portable C API), but it's not the same thing. – Artefacto Oct 20 '10 at 14:07
  • I thought the same, but my C kung-fu is not strong. – Elzo Valugi Oct 20 '10 at 16:49

1 Answers1

5

The 7z file format can use various compression algorithms, so you might be able to decompress the archive with one of the existing utilities for bzip2 or deflate.

I found a 7z PHP class as well, and you are lucky since it's still being developed. Here is the latest version.

rmunn
  • 29,094
  • 9
  • 62
  • 91
bobdiaes
  • 1,067
  • 11
  • 9
  • "At this moment it has been tested only on Linux, and restricts itself to listing an archive's contents. It can also return the Content-Type of all files. It can also return the Charset + contents of `text/...' files. It can also return the content of archives stored within the Archive." – Elzo Valugi Oct 08 '10 at 08:22
  • 1
    Well that's better than nothing, I guess. Perhaps using the [LZMA SDK](http://www.7-zip.org/sdk.html) and [SWIG for PHP](http://www.swig.org/Doc1.3/Php.html) could be an easy way to make a 7z extension. Although, I'm not sure that's considerably better than using a command-line program through exec(). – bobdiaes Oct 08 '10 at 08:37
  • Since this answer was posted, there's now a newer version of the PHP class, version 0.13.3 (latest version when answer was written was 0.13.1). I'm updating the "latest version" link in the answer to point to version 0.13.3, for those who (like me) will find this answer through a Google search later on. – rmunn Oct 15 '14 at 07:16
  • However, it still doesn't extract files, just lists them. Which is a pretty major missing feature. – rmunn Oct 15 '14 at 07:25
  • Yes, wouldn't accept that as an answer... still nothing. – Flash Thunder Jan 18 '15 at 04:19
  • 4
    The links are dead! I would really appreciate it if one of you could upload the source files, I need this so badly! – hedgehog90 Sep 25 '15 at 16:28