Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
You can install Drupal successfully without the zip
extension.
Then executing \Drupal::service('plugin.manager.archiver')->getInstance(['filepath' => 'foo.zip']);
yields a fatal:
Class 'ZipArchive' not found
Proposed resolution
Either:
A: Add zip
to the list of required extensions for Drupal
B: Remove the zip
archiver plugin if the zip
extension is missing. This could be done with a one-off implementation of hook_archiver_info_alter()
in System module. Alternatively, ArchiverManager
could allow archiver plugin definitions to specify a required PHP extension and filter those out where the extension is missing.
Comments
Comment #2
tstoecklerBtw this was introduced all the way back in #1950726: Convert hook_archiver_info into the New Shiny(TM). The old D7 info hook had a
function_exists('zip_open')
check, and that was simply dropped in the Plugin conversion.Comment #3
cilefen CreditAttribution: cilefen as a volunteer commentedI feel "ArchiverManager could allow archiver plugin definitions to specify a required PHP extension and filter those out where the extension is missing." is the best way to go, if we can do it in a backwards-compatible way.
Comment #10
longwaveBoth the proposed resolutions are being discussed in #3163123: Error: Class 'ZipArchive' not found in Drupal\Core\Archiver\Zip->__construct() (line 30 of core/lib/Drupal/Core/Archiver/Zip.php).