在Mac上安装Laravel时缺少PHP扩展

时间:2018-07-15 12:58:23

标签: laravel composer-php

我正在尝试使用终端在Mac上安装laravel,但出现此错误。我有php版本7.3和最新版本的composer。如何在Mac上使用终端下载php扩展。

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.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.
    - laravel/installer v2.0.1 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 your .ini files:
    - /usr/local/php5/lib/php.ini
    - /usr/local/php5/php.d/10-extension_dir.ini
    - /usr/local/php5/php.d/20-extension-opcache.ini
    - /usr/local/php5/php.d/40-curl.ini
    - /usr/local/php5/php.d/40-openssl.ini
    - /usr/local/php5/php.d/50-extension-apcu.ini
    - /usr/local/php5/php.d/50-extension-curl.ini
    - /usr/local/php5/php.d/50-extension-gmp.ini
    - /usr/local/php5/php.d/50-extension-igbinary.ini
    - /usr/local/php5/php.d/50-extension-imap.ini
    - /usr/local/php5/php.d/50-extension-intl.ini
    - /usr/local/php5/php.d/50-extension-mcrypt.ini
    - /usr/local/php5/php.d/50-extension-mongodb.ini
    - /usr/local/php5/php.d/50-extension-mssql.ini
    - /usr/local/php5/php.d/50-extension-pdo_pgsql.ini
    - /usr/local/php5/php.d/50-extension-pgsql.ini
    - /usr/local/php5/php.d/50-extension-propro.ini
    - /usr/local/php5/php.d/50-extension-raphf.ini
    - /usr/local/php5/php.d/50-extension-readline.ini
    - /usr/local/php5/php.d/50-extension-redis.ini
    - /usr/local/php5/php.d/50-extension-xsl.ini
    - /usr/local/php5/php.d/99-liip-developer.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, reverting ./composer.json to its original content.

1 个答案:

答案 0 :(得分:4)

最近遇到同样的问题。这就是为我解决的问题:

  1. 从brew(brew install php)下载PHP
  2. 让系统使用该版本的PHP代替预先安装的PHP
  3. 编辑~/.zshrc~/.bashrc以添加以下内容:
export PATH="/usr/local/opt/php@7.3/bin:$PATH"
export PATH="/usr/local/opt/php@7.3/sbin:$PATH"

然后运行

source ~/.zshrc
or
source ~/.bashrc

在我完成Laravel的安装后,没有任何问题!

相关问题