If you are running into this error while using a Docker image and that you are calling the class properly, or that the error comes from an up-to-date library, then the zip
module is probably missing.
Assuming we use docker-compose
, we can confirm it's missing by running docker-compose run php php -m
for instance and see that zip
is not listed.
To install it in your image, modify your Dockerfile
so it does the same as this example.
FROM php:7.3-apache
RUN set -eux \
&& apt-get update \
&& apt-get install -y libzip-dev zlib1g-dev \
&& docker-php-ext-install zip
Then rebuild the image with docker-compose build php
and you are good to go.