Composer require ext-zip fails

Composer require ext-zip fails

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Composer require ext-zip fails

When PHPStorm suggests you run composer require ext-zip to resolve an issue, it is usually pointing toward a missing native extension. The error message you are seeing—Your requirements could not be resolved to an installable set of packages followed by a reversion of your composer.json—indicates that Composer cannot find a matching package in its repositories. This happens because ext-zip is not a PHP library distributed via Packagist; it is a compiled C extension.

Composer operates on the principle of downloading pure PHP code from remote repositories like Packagist. When you attempt to require a package named ext-zip, Composer looks for a JSON metadata file describing a PHP library, but none exists under that name. The confusion arises because many modern PHP projects rely on the zip extension for archiving functionality, and IDEs often recommend installing it to ensure certain packages work correctly. However, treating a compiled extension as a Composer dependency leads to this specific resolution failure.

To fix this, you must distinguish between installing a library and installing a system-level extension. The package that actually provides the ZIP functionality is zip, not ext-zip. If your goal is to enable the native PHP zip extension so that packages like league/flysystem or symfony/filesystem can write archives, you should install the underlying system dependency rather than trying to fetch it through Composer.

On Linux systems, this typically involves using your package manager:

# Debian/Ubuntu
sudo apt-get install php-zip

# RHEL/CentOS/Fedora
sudo dnf install php-zip
# or
sudo yum install php-zip

Once installed, you need to ensure the extension is loaded in your PHP configuration. You can check if ext-zip.so is active by running:

php -m | grep zip

If the module is not listed, you must enable it manually. On systems using php.ini, add or uncomment the line:

extension=zip

Alternatively, if you are managing extensions via OPcache or a specific SAPI configuration (like FastCGI), ensure the path to ext-zip.so is correctly referenced in your php.ini or loaded dynamically via CLI arguments.

On macOS, particularly with Homebrew, the process involves installing PHP and its extensions together:

brew install php
# Then ensure zip is included in the php.ini found by brew

If you are working within a Laravel project (often where league/flysystem or similar storage drivers become relevant), ensuring the zip extension is present is crucial for file system operations involving archives. While some third-party packages offer alternative implementations via pure PHP (like paragonie/ezingress in specific contexts or other ZIP libraries), these are generally slower and less memory-efficient than the native C extension. Therefore, the industry standard remains installing the zip extension system-wide rather than trying to shim it with a Composer package named after the extension itself.

If you encounter issues where the extension loads but causes segfaults or memory errors, it might indicate an incompatibility between your PHP version and the compiled library. In such cases, rebuilding PHP from source with the --with-libzip flag or ensuring you have the development headers (libzip-dev on Debian/Ubuntu) installed is necessary.

Remember that Composer manages dependencies for code, while package managers handle native binaries and extensions. Mixing these two responsibilities by requiring a system extension as a Composer package is a common source of confusion that results in the "could not be resolved" error you encountered initially.

Our network