简体   繁体   中英

Composer install Laravel: Your requirements could not be resolved to an installable set of packages

I'm trying to install Laravel using composer for the first time.

Following the documentation on https://laravel.com/docs/5.1 , I tried doing it with the command sudo composer global require "laravel/installer" .

The output I got is pasted below:

 Changed current directory to /home/israel/.composer Using version ^2.0 for laravel/installer ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - laravel/installer v2.0.1 requires ext-zip * -> the requested PHP extension zip is missing from your system. - laravel/installer v2.0.0 requires ext-zip * -> the requested PHP extension zip is missing from your system. - Installation request for laravel/installer ^2.0 -> satisfiable by laravel/installer[v2.0.0, v2.0.1]. To enable extensions, verify that they are enabled in those .ini files: - /etc/php/7.2/cli/php.ini - /etc/php/7.2/cli/conf.d/10-opcache.ini - /etc/php/7.2/cli/conf.d/10-pdo.ini - /etc/php/7.2/cli/conf.d/15-xml.ini - /etc/php/7.2/cli/conf.d/20-calendar.ini - /etc/php/7.2/cli/conf.d/20-ctype.ini - /etc/php/7.2/cli/conf.d/20-curl.ini - /etc/php/7.2/cli/conf.d/20-dom.ini - /etc/php/7.2/cli/conf.d/20-exif.ini - /etc/php/7.2/cli/conf.d/20-fileinfo.ini - /etc/php/7.2/cli/conf.d/20-ftp.ini - /etc/php/7.2/cli/conf.d/20-gettext.ini - /etc/php/7.2/cli/conf.d/20-iconv.ini - /etc/php/7.2/cli/conf.d/20-json.ini - /etc/php/7.2/cli/conf.d/20-mbstring.ini - /etc/php/7.2/cli/conf.d/20-phar.ini - /etc/php/7.2/cli/conf.d/20-posix.ini - /etc/php/7.2/cli/conf.d/20-readline.ini - /etc/php/7.2/cli/conf.d/20-shmop.ini - /etc/php/7.2/cli/conf.d/20-simplexml.ini - /etc/php/7.2/cli/conf.d/20-sockets.ini - /etc/php/7.2/cli/conf.d/20-sysvmsg.ini - /etc/php/7.2/cli/conf.d/20-sysvsem.ini - /etc/php/7.2/cli/conf.d/20-sysvshm.ini - /etc/php/7.2/cli/conf.d/20-tokenizer.ini - /etc/php/7.2/cli/conf.d/20-wddx.ini - /etc/php/7.2/cli/conf.d/20-xmlreader.ini - /etc/php/7.2/cli/conf.d/20-xmlwriter.ini - /etc/php/7.2/cli/conf.d/20-xsl.ini You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode. Installation failed, deleting ./composer.json.

Does this mean PHP isn't installed?

Just run sudo apt-get install php7.2-zip && sudo apt-get install php-zip . After which you would run the command ( sudo composer global require "laravel/installer" ) again.

It should work just fine.

It actually did. :)

If you try

sudo apt-get install php7.2-zip

and you run into the error :

sudo: apt-get: command not found

Then, try it with homebrew instead:

brew install php

This worked for me. Hopefully it saves someone a few minutes of extra head scratching :) Happy coding!

Have a look at the Laravel requirements:

PHP >= 7.1.3
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Ctype PHP Extension
JSON PHP Extension

Do you meet them? Your Error message states, that your environment does not meet the PHP version and extensions, so you have to install them first. Once you have installed the correct PHP version and the corresponding extensions, composer will be able to install laravel as desired.

Hope this helps! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM