Skip to content

Releases: mateuszanella/php-ext-xz

v2.1.0

Choose a tag to compare

@mateuszanella mateuszanella released this 12 Aug 22:04

v2.1.0

Raw LZMA1/LZMA2 stream support and a format-aware API, allowing the extension to build custom containers (e.g. archives) on top of bare LZMA codec streams.

Breaking Changes

  • xz_encode_init() / xz_decode_init() signatures changed to (int $format, array $options):
    • xz_encode_init(XZ_CHECK_CRC64, [...])xz_encode_init(XZ_FORMAT_XZ, ['check' => XZ_CHECK_CRC64, ...])
    • xz_decode_init($flags, $memory_limit)xz_decode_init(XZ_FORMAT_XZ, ['flags' => ..., 'memory_limit' => ...])
  • xzencode() signature changed to xzencode(string $data, int $level = -1, int $format = XZ_FORMAT_XZ).
  • xzdecode() gained a $memory_limit parameter.

New Features

Raw Streams

XZ_FORMAT_RAW produces and consumes bare LZMA1/LZMA2 streams with no container, header, or integrity check.

Codec Control

  • XZ_FILTER_LZMA1 / XZ_FILTER_LZMA2 select the codec filter.
  • dict_size, lc, lp, and pb can be used to tune LZMA parameters.

Codec Properties

xz_encode_get_properties() returns the codec property bytes needed to embed a stream in a custom container:

  • 1 byte for LZMA2
  • 5 bytes for LZMA1

One-Shot Raw Encoding

xzencode($data, -1, XZ_FORMAT_RAW) emits a raw LZMA2 stream.

xzdecode() accepts an explicit memory limit for controlling decoder resource usage.

New Constants

  • XZ_FORMAT_XZ
  • XZ_FORMAT_RAW
  • XZ_FILTER_LZMA1
  • XZ_FILTER_LZMA2

Notes

  • No .xz-only behavior has changed. Defaults remain fully backward-compatible, so xz_encode_init() and xzencode() with no arguments continue to work.
  • The stream wrapper (xzopen) remains .xz-container-only. Level and memory usage are configurable via the mode string and stream context options.
  • Internal cleanup: option parsing and buffer-size constants have been moved out of the main header.

v2.0.0

Choose a tag to compare

@mateuszanella mateuszanella released this 12 Aug 13:05

v2.0.0 — Incremental Compression & Decompression

This release adds a full incremental streaming API, mirroring zlib's DeflateContext / InflateContext pattern, plus a major internal refactor and expanded test coverage.

Incremental API

Two new context classes with factory, feed, and finish functions:

// Encode
$ctx = xz_encode_init(XZ_CHECK_CRC64, ['level' => 6]);
$out  = xz_encode_add($ctx, 'Hello, ');
$out .= xz_encode_add($ctx, 'World!');
$out .= xz_encode_finish($ctx);

// Decode
$ctx = xz_decode_init(XZ_CONCATENATED);
$dec = xz_decode_add($ctx, $compressed);
$dec .= xz_decode_finish($ctx);
$status = xz_decode_get_status($ctx);        // 1 = finished
$bytes  = xz_decode_get_read_len($ctx);    // compressed bytes consumed

8 new functions: xz_encode_init, xz_encode_add, xz_encode_finish, xz_decode_init, xz_decode_add, xz_decode_finish, xz_decode_get_status, xz_decode_get_read_len

7 new constants: XZ_CHECK_NONE, XZ_CHECK_CRC32, XZ_CHECK_CRC64, XZ_CHECK_SHA256, XZ_FAIL_FAST, XZ_IGNORE_CHECK, XZ_CONCATENATED

Internal refactor

  • Codebase split into one-file-per-concept (xz_encode.c, xz_decode.c, xz_encode_context.c, xz_decode_context.c, xz_fopen_wrapper.c)
  • All version guards consolidated in xz_compat.h
  • Argument parsing migrated to ZEND_PARSE_PARAMETERS_START / Z_PARAM_* macros
  • Fixed memory leak on lzma_end in encoder error paths

v1.2.0

Choose a tag to compare

@mateuszanella mateuszanella released this 26 Sep 11:17
87e7986

Added a way to dynamically set the compression level when using xzencode. Now, the default is to use the INI value xz.compression_level, but this value may be overwritten using the second function parameter.

v1.1.5

Choose a tag to compare

@mateuszanella mateuszanella released this 25 Sep 11:22
c8bf452
  • Updated README documentation to be a bit more more comprehensive.

Initial release

Choose a tag to compare

@mateuszanella mateuszanella released this 19 Sep 11:14

Initial release of the extension, published at v1.1.4.