Replace PclZip with ZipArchive

Created on 9 April 2025, 15 days ago

Problem/Motivation

PclZip seems to be no longer well supported. ZipArchive is the standard PHP class for creating zip files and is more reliable.
However, it requires the PHP zip extension, which might not be available on all shared hosting environments.

Proposed resolution

Replace PclZip with ZipArchive.

Remaining tasks

  • Update the code to use ZipArchive instead of PclZip.
  • Test compatibility with different environments.
  • Document the requirement for the PHP zip extension.
๐Ÿ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡พUruguay ruby232 Montevideo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ruby232
  • First commit to issue fork.
  • ๐Ÿ‡บ๐Ÿ‡พUruguay jborgesr
  • ๐Ÿ‡บ๐Ÿ‡พUruguay apereira23

    I assign myself this issue to work on.

  • ๐Ÿ‡บ๐Ÿ‡พUruguay apereira23

    Requirements for Using ZipArchive in Drupal

    To ensure ZipArchive works correctly in your Drupal project, you need to consider the following:

    The PHP zip extension must be enabled

    The ZipArchive class is not an external library but part of PHPโ€™s zip extension. If your server doesnโ€™t have this extension enabled, ZipArchive wonโ€™t be available.
    How to check if the extension is activated: Run this command on the server:

    php -m | grep zip
    

    If zip does not appear in the list of modules, the extension is likely disabled.
    How to enable it on Linux (for manually installed PHP):

    sudo apt-get install php-zip
    sudo systemctl restart apache2
    

    For Windows, make sure your php.ini includes this line:

    extension=zip
    

    I believe the steps described above should be added to the Additional Requirements section of the project page template when making this change.

  • ๐Ÿ‡บ๐Ÿ‡พUruguay ruby232 Montevideo

    @apereira23
    I think the best option is to create a plugin for generating ZIP files, and add a configuration form to allow users to select the option to create the ZIP.
    Some sites might not have the ZIP extension installed, so in that case, it would be a good idea to use a third-party library to compress files.

Production build 0.71.5 2024