PHP error: The zip extension and unzip command are both missing, skipping.
Depending on your flavour of Linux and PHP version these may vary.
(sudo) yum install zip unzip php-zip
(sudo) apt install zip unzip php-zip
This is a very commonly asked question, you'll be able to find more useful info in the aether by searching <distro> php <version> zip extension
.
I cannot install Laravel with Composer (ext-zip extension is missing)
- Make sure to restart the webserver after the change
php -m
to list the compiled modules- it happened to me once (on plesk) that composer was using a different php version than to use
php
itself - You could try
php composer.phar(the location of that)
and check the results
If Installing laravel is what matters here
here are some possible solutions
composer create-project laravel/laravel [dir]
- or
git clone https://github.com/laravel/laravel.git
thencd
to that directory, usually laravel, socd laravel
thencomposer install
Can't install laravel installer via composer
It says that it requires zip extension
laravel/installer v1.4.0 requires ext-zip...
Install using (to install the default version):
sudo apt install php-zip
Or, if you're running a specific version of PHP:
# For php v7.0
sudo apt-get install php7.0-zip
# For php v7.1
sudo apt-get install php7.1-zip
# For php v7.2
sudo apt-get install php7.2-zip
# For php v7.3
sudo apt-get install php7.3-zip
# For php v7.4
sudo apt-get install php7.4-zip
Docker image build with PHP zip extension shows bundled libzip is deprecated warning
It looks like PHP no longer bundles libzip. You need to install it. You install zlib1g-dev
, but instead install libzip-dev
. This installs zlib1g-dev
as a dependency and allows the configure
script to detect that libzip
is installed.
For PHP < 7.3, you then need to
docker-php-ext-configure zip --with-libzip
before performing the installation with
docker-php-ext-install zip
as the last warning indicates.
In short: change the relevant part of your Dockerfile to
For PHP < 7.3
#install some base extensions
RUN apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip
For PHP >= 7.3
#install some base extensions
RUN apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-install zip
I have verified that this builds as expected.
In case you are not using the Docker PHP base image, things may be much easier. For example, for Alpine the following Dockerfile will get you PHP 7 with the zip extension installed.
FROM alpine:latest
RUN apk update && apk upgrade
RUN apk add php7 php7-zip composer
Docker php adding Zip Extension
The solution is as simple as removing the
docker-php-ext-configure zip --with-libzip
line entirely for PHP >= 7.4. Defaults are sufficient.
As commented by hackel on their issue tracker: https://github.com/laradock/laradock/issues/2421#issuecomment-567728540
So a working Dockerfile would be:
FROM php:7.4-fpm-alpine
RUN apk add --no-cache \
libzip-dev \
zip \
&& docker-php-ext-install zip
Related Topics
Session_Start() Creates New Session Every Refresh
PHP Allocate Color Without Image Resource
PHP Sessions Login with Remember Me
Merge 2 Arrays and Sum the Values (Numeric Keys)
Phpunit Best Practices to Organize Tests
PHP Loop: Add a Div Around Every Three Items Syntax
Get All the Images from a Folder in PHP
Best Way to Do a Weighted Search Over Multiple Fields in MySQL
This Is the .Htaccess Code in Wordpress. Can Someone Explain How It Works
Why Are Escape Characters Being Added to the Value of the Hidden Input
How to Implement MVC from Scratch in PHP
PHP If Single or Double Equals
How to Design a Hierarchical Role Based Access Control System