140

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"
miken32
  • 42,008
  • 16
  • 111
  • 154
Andreas Sauer
  • 1,407
  • 2
  • 8
  • 6

14 Answers14

326

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
Joseph Erickson
  • 2,304
  • 20
  • 29
Alex
  • 4,621
  • 1
  • 20
  • 30
  • 1
    Works perfectly but shouldn't this be in the composer install? It's a dependency manager...missing a dependency. Maybe it was Cannonical that missed the inclusion. – Tyler Christian May 23 '18 at 05:52
  • 2
    @TylerChristian, composer install manages PHP dependencies, php7.0-zip is a system package. It can't be solved by composer. Theoretically, it's possible to add hook that installs system package as well, but it will require sudo access, which is REALLY bad practice. – Alex May 23 '18 at 08:06
  • 4
    `requires ext-zip` is a pretty unhelpful message. Should say `requires php-zip or phpX.X-zip` at least. – Henry Jul 10 '18 at 21:18
  • 2
    for mac os users please user Homebrew instead. You don't need to run brew commands as root. example : brew install php7.0-zip – Hosny Ben May 24 '20 at 01:55
55

FOR MAC USERS with CATALINA

First, install homebrew. Then, say

brew install php@7.3
brew link php@7.3

restart the console and run the laravel installer

  • The question asks about Ubuntu, not Mac. – Martijn Pieters Apr 10 '20 at 08:10
  • Please add some further explanation to your answer - how does this command resolve the given problem? Is there any problem in simply installing the given extension without installing other programs first? – Nico Haase Jul 29 '20 at 12:17
  • addition, `brew link php@7.3` didn't work. It gave me a warning. I needed to force it using `brew link php@7.3 --force`. – Jaydip Kalkani Aug 29 '20 at 03:41
23

On centos 7 I have used:

yum install php-pecl-zip

because any other solution didn't work for me.

Evan
  • 1,004
  • 11
  • 12
  • The question asks about Ubuntu, not CentOS. – Martijn Pieters Apr 10 '20 at 08:07
  • This is exactly what I was looking for, thanks. yum install php-zip doesn't work on CentOS 7. – GTS Joe Jun 12 '20 at 23:01
  • 1
    for specific versions of php use one of the following package names after "yum install": `php54-php-pecl-zip php55-php-pecl-zip php56-php-pecl-zip php70-php-pecl-zip php71-php-pecl-zip php72-php-pecl-zip php73-php-pecl-zip php74-php-pecl-zip php80-php-pecl-zip` – Art Williams Feb 19 '21 at 17:29
19

For PHP7.1 install this

sudo apt-get install php7.1-zip
7

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 php@7.3

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

echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.zshrc

echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.zshrc

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

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

Marcos Curvello
  • 873
  • 13
  • 25
5

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

sudo apt-get install php7.2-zip
Max von Hippel
  • 2,856
  • 3
  • 29
  • 46
Amit Khanna
  • 1
  • 1
  • 7
5

Centos 7 with PHP7.2:

sudo yum --enablerepo=remi-php72 install php-pecl-zip
Amirul
  • 542
  • 6
  • 15
3

to know your php version

php -v 

for php 7.3.0

sudo apt-get install php7.3-zip
  • I'm getting this error E: Unable to locate package php7.3-zip E: Couldn't find any package by glob 'php7.3-zip' E: Couldn't find any package by regex 'php7.3-zip' – mehmetakkus Jul 14 '19 at 20:12
3
V=`php -v | sed -e '/^PHP/!d' -e 's/.* \([0-9]\+\.[0-9]\+\).*$/\1/'` \
sudo apt-get install php$V-zip
borodatych
  • 316
  • 4
  • 9
2

For Mac with Macports,

# port install php71-zip
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Toby
  • 49
  • 2
2

For PHP 7.2 in Ubuntu 18.04 LTS

sudo apt-get install php7.2-zip

Works like a charm

Ian Samz
  • 1,743
  • 20
  • 20
2

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

Ankur Tiwari
  • 2,762
  • 2
  • 23
  • 40
2

For macOs users you can use Homebrew instead :

# For php v7.0
brew install php@7.0

# For php v7.1
brew install php@7.1

# For php v7.2
brew install php@7.2

# For php v7.3
brew install php@7.3

# For php v7.4
brew install php@7.4
Hosny Ben
  • 138
  • 1
  • 6
  • Please add some further explanation to your answer - how does this list of commands resolve the given problem? – Nico Haase Jul 29 '20 at 12:16
1

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

Fil
  • 8,225
  • 14
  • 59
  • 85