Andreas Sauer
Andreas Sauer

Reputation: 1447

Can't install package via composer: PHP extension zip is missing

I'm trying to install laravel installer with the composer on my Ubuntu PC, but I get this error during the installation. `Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/installer v1.4.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - laravel/installer v1.4.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - Installation request for laravel/installer ^1.4 -> satisfiable by laravel/installer[v1.4.0, v1.4.1].

  To enable extensions, verify that they are enabled in those .ini files:
    - /etc/php/7.0/cli/php.ini
    - /etc/php/7.0/cli/conf.d/10-opcache.ini
    - /etc/php/7.0/cli/conf.d/10-pdo.ini
    - /etc/php/7.0/cli/conf.d/20-calendar.ini
    - /etc/php/7.0/cli/conf.d/20-ctype.ini
    - /etc/php/7.0/cli/conf.d/20-exif.ini
    - /etc/php/7.0/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.0/cli/conf.d/20-ftp.ini
    - /etc/php/7.0/cli/conf.d/20-gettext.ini
    - /etc/php/7.0/cli/conf.d/20-iconv.ini
    - /etc/php/7.0/cli/conf.d/20-json.ini
    - /etc/php/7.0/cli/conf.d/20-phar.ini
    - /etc/php/7.0/cli/conf.d/20-posix.ini
    - /etc/php/7.0/cli/conf.d/20-readline.ini
    - /etc/php/7.0/cli/conf.d/20-shmop.ini
    - /etc/php/7.0/cli/conf.d/20-sockets.ini
    - /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.0/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.0/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.0/cli/conf.d/20-tokenizer.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
`

The error appears then I use this comment:

composer global require "laravel/installer"

Upvotes: 144

Views: 186048

Answers (15)

farid teymouri
farid teymouri

Reputation: 191


# for (php:8.2-fpm)

# Install system dependencies and required PHP extensions
RUN apt-get update && apt-get install -y \
    git \
    curl \
    libpng-dev \
    libonig-dev \
    libxml2-dev \
    libzip-dev \
    zip \
    unzip \
    && docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd soap zip

# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# other codes...

Using the --progress=plain option with docker-compose build can significantly improve your ability to debug issues during the image build process. This option changes the output format to a plain text format that is easier to read and provides more detailed information about each step in the Dockerfile.

Usage :

docker-compose build --progress=plain

What Does docker-php-ext-install Do?

Command Overview: The docker-php-ext-install script is provided by the official PHP Docker images. It simplifies the installation of common PHP extensions within the container.

PHP Extensions: The listed extensions (pdo_mysql, mbstring, exif, pcntl, bcmath, gd, soap) are often used in PHP applications:

  • pdo_mysql: For database access using PDO with MySQL.
  • mbstring: For multibyte string handling.
  • exif: For reading metadata from images.
  • pcntl: For process control.
  • bcmath: For arbitrary precision mathematics.
  • gd: For image processing.
  • soap: For working with SOAP web services.

Upvotes: 0

Alex
Alex

Reputation: 4811

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

Upvotes: 332

Hosny Ben
Hosny Ben

Reputation: 136

For macOs users you can use Homebrew instead :

# For php v7.0
brew install [email protected]

# For php v7.1
brew install [email protected]

# For php v7.2
brew install [email protected]

# For php v7.3
brew install [email protected]

# For php v7.4
brew install [email protected]

Upvotes: 2

Marcos Curvello
Marcos Curvello

Reputation: 917

If you're facing this issue with macOS Catalina, I recommend these steps:

  1. Install Homebrew (if you haven't already done so): head over to brew.sh or simply run this command: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. Run brew install [email protected]

  3. Update your $PATH variable to include the newly installed version of php:

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

  1. Reload your shell preferences script $ source ~/.zshrc or source ~/.bashrc

  2. Finally, install laravel: composer global require laravel/installer

Upvotes: 7

Mikołaj Marciniak
Mikołaj Marciniak

Reputation: 890

FOR MAC USERS with CATALINA

First, install homebrew. Then, say

brew install [email protected]
brew link [email protected]

restart the console and run the laravel installer

Upvotes: 55

borodatych
borodatych

Reputation: 316

V=`php -v | sed -e '/^PHP/!d' -e 's/.* \([0-9]\+\.[0-9]\+\).*$/\1/'` \
sudo apt-get install php$V-zip

Upvotes: 3

Ankur Tiwari
Ankur Tiwari

Reputation: 2782

zip extension is missing, You can avoid this error by simple running below command, It will take version by default

sudo apt-get install php-zip

In case you need any specific version, You need to mention a specific version of your php, Suppose I need to install X version of php-zip then the command will be.

sudo apt-get install phpX-zip  

Replace X with your required version, In my case, it is X = 7.3

Upvotes: 2

mohamed elshazly
mohamed elshazly

Reputation: 548

to know your php version

php -v 

for php 7.3.0

sudo apt-get install php7.3-zip

Upvotes: 3

Fil
Fil

Reputation: 8863

I am using WSL with ubuntu 16.04 LTS version with php 7.3 and laravel 5.7

sudo apt-get install php7.3-zip

Work for me

Upvotes: 1

Ian Samz
Ian Samz

Reputation: 2109

For PHP 7.2 in Ubuntu 18.04 LTS

sudo apt-get install php7.2-zip

Works like a charm

Upvotes: 2

Amirul
Amirul

Reputation: 582

Centos 7 with PHP7.2:

sudo yum --enablerepo=remi-php72 install php-pecl-zip

Upvotes: 5

Amit Khanna
Amit Khanna

Reputation: 1

For Ubuntu 16.04, I have used this command for PHP7.2 and it worked for me.

sudo apt-get install php7.2-zip

Upvotes: 5

Evan
Evan

Reputation: 1082

On centos 7 I have used:

yum install php-pecl-zip

because any other solution didn't work for me.

Upvotes: 23

Toby
Toby

Reputation: 49

For Mac with Macports,

# port install php71-zip

Upvotes: 2

Muhammad F. Musad
Muhammad F. Musad

Reputation: 867

For PHP7.1 install this

sudo apt-get install php7.1-zip

Upvotes: 19

Related Questions