php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63880 Implement lzma compression (e.g. xz, lzip)
Submitted: 2013-01-01 00:03 UTC Modified: 2019-08-19 10:55 UTC
Votes:35
Avg. Score:4.7 ± 0.6
Reproduced:28 of 29 (96.6%)
Same Version:14 (50.0%)
Same OS:15 (53.6%)
From: tobias at freiwuppertal dot de Assigned:
Status: Suspended Package: *Compression related
PHP Version: 7.4.0 OS: Any
Private report: No CVE-ID: None
 [2013-01-01 00:03 UTC] tobias at freiwuppertal dot de
Description:
------------
http://php.net/manual/en/refs.compression.php

^ xz is not implemented yet, sadly. :-/

https://en.wikipedia.org/wiki/Xz

The compression results are usually significantly better than those of bzip2. This feature request currently blocks another one at phpbb:
http://tracker.phpbb.com/browse/PHPBB3-11300


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-24 08:43 UTC] payden at paydensutherland dot com
I started working on a xz extension for PHP.  I got the basics of the writing 
half of it worked out tonight, which is definitely the easy part.  :)  I'll let 
you know when I get a workable extension for testing.

This is what I have so far:

payden@arwen:~$ cat test.php
<?php
ini_set('display_errors','on');
error_reporting(E_ALL);
$fh = fopen("php://stdin", "r");
$xz = xzopen("/tmp/test.xz", "w");
while (!feof($fh)) {
  fwrite($xz, fgets($fh, 1000));
}
fclose($xz);
?>
payden@arwen:~$ php test.php
testing this out....
stdin...
blah.
payden@arwen:~$ xzcat /tmp/test.xz
testing this out....
stdin...
blah.
payden@arwen:~$
 [2013-02-24 14:23 UTC] tobias at freiwuppertal dot de
Thank you very much! :-)
 [2013-02-25 01:51 UTC] payden at paydensutherland dot com
I've only had a couple of days so far, so I must stress that this is probably very 
buggy and I do NOT recommend running this extension on anything considered 
production, but feel free to test it out on a development machine, i.e. your 
personal Linux box. :)

Also, you'll be able to follow my progress with it if you want: 
https://github.com/payden/php-xz
 [2013-02-25 16:31 UTC] tobias at freiwuppertal dot de
Starred & watching :-)
 [2016-12-07 14:37 UTC] tobias at freiwuppertal dot de
-PHP Version: Irrelevant +PHP Version: 7.1.0
 [2016-12-07 14:37 UTC] tobias at freiwuppertal dot de
Defining a version number to make people aware of this bug. 2013-01-01!
 [2016-12-07 14:43 UTC] tobias at freiwuppertal dot de
By the way, ironically, php itself (!) is distributed as an xz-compressed archive:
https://secure.php.net/downloads.php
 [2017-06-03 07:28 UTC] asmqb7 at gmail dot com
Wanted to bump this and request that

- Some tests are written to provide some reassurance that the extension is not so likely to bomb out under production load (case in point: one of the latest commits (from 4 years ago!) is "Fix SIGSEGV."!!)

- Stream compression be properly supported - the use case I wanted to use this for is not strictly file-based (I'm doing my own file/protocol/format management).

- LZMA format options be surfaced

- Low-level functionality such as (for example) LZMA protocol streams (not PHP streams!) are exposed for people who need to shove a lot of data through LZMA2 with fine control

Thanks so much for contributing LZMA2 support to PHP. There are no other extensions that support this form of compression.

FWIW, because php-xz does not support #2 above I'll have to look for other solutions :( so I'm just adding this to the record to note the kind of demand that's out there.
 [2018-05-08 17:47 UTC] theo dot fidry at gmail dot com
Hi,

If that feature is ever supported (which I hope and would be awesome), it would also be a nice addition to add it as a possible compression mode for PHARs as well (see https://github.com/humbug/box/issues/211#issuecomment-387480271)
 [2018-05-08 18:00 UTC] spam2 at rhsoft dot net
for .phar XZ is nonsense in 2018, compare it with zstd and look at ressources / compression-rates
 [2018-05-08 22:06 UTC] tobias at freiwuppertal dot de
-Operating System: Irrelevant +Operating System: Any -PHP Version: 7.1.0 +PHP Version: 7.2.5
 [2018-05-08 22:06 UTC] tobias at freiwuppertal dot de
Upgrading to 7.2.5
 [2018-10-25 18:52 UTC] tobias at freiwuppertal dot de
-PHP Version: 7.2.5 +PHP Version: 7.3.0RC4
 [2018-10-25 18:52 UTC] tobias at freiwuppertal dot de
Updating to RC4, hopefully increasing visibility. Submitted 2013-01-01, still open.
 [2018-10-25 18:54 UTC] spam2 at rhsoft dot net
xz is way too slow for most usecases - period
lern about zstd and complain lack of that
 [2018-10-25 21:39 UTC] tobias at freiwuppertal dot de
This bug is about xz, not other types of compression. It is specifically not about .phar archives, but instead writing and reading a widely used archive format that is not specific to PHP. GIMP has implemented .xcfxz files recently, and as mentioned, PHP itself is being distributed in .xz format. Please avoid off topic comments. Thank you.
 [2019-01-25 01:13 UTC] tobias at freiwuppertal dot de
-PHP Version: 7.3.0RC4 +PHP Version: 7.3.1
 [2019-01-25 01:13 UTC] tobias at freiwuppertal dot de
.
 [2019-08-19 00:24 UTC] tobias at freiwuppertal dot de
-PHP Version: 7.3.1 +PHP Version: 7.4.0
 [2019-08-19 00:24 UTC] tobias at freiwuppertal dot de
7.3.1 -> 7.4.0
 [2019-08-19 09:37 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2019-08-19 09:37 UTC] cmb@php.net
This feature request requires discussion on the internals@ mailing
list[1], and perhaps the RFC process[2].  Until this proceeds, I'm
suspending this ticket.

[1] <https://www.php.net/mailing-lists.php>
[2] <https://wiki.php.net/rfc/howto>
 [2019-08-19 10:55 UTC] tobias at freiwuppertal dot de
-Summary: Implement xz compression +Summary: Implement lzma compression (e.g. xz, lzip)
 [2019-08-19 10:55 UTC] tobias at freiwuppertal dot de
Thanks.

https://news-web.php.net/php.internals/106651
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 02 07:01:30 2024 UTC