在Mac上安装Laravel maatwebsite/excel composer时出现错误

17

尝试通过composer在XAMPP 7.1.32 rev 1上为Mac安装maatwebsite/excel。如何在Mac的XAMPP中启用这些扩展,或者是否存在其他问题,请帮帮我。

composer install
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
    - maatwebsite/excel 3.1.10 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.11 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.12 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.13 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.14 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.15 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.16 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.17 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.7 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.8 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.9 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.0 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.1 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.2 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.3 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.4 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.5 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.6 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - phpoffice/phpspreadsheet 1.9.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.8.2 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.8.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.8.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.7.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.6.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.5.2 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.5.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.5.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.4.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.4.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - Installation request for maatwebsite/excel ^3.1 -> satisfiable by maatwebsite/excel[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.14, 3.1.15, 3.1.16, 3.1.17, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9].

我的PHP信息中启用了zip。

在此输入图片描述


你会访问这个链接吗 - https://dev59.com/-VYM5IYBdhLWcg3w5jJN - Rashed Hasan
你目前尝试了什么?你卡在哪儿了?PHP的CLI版本和你的Web服务器模块不共享它们的配置是相当常见的情况。 - Nico Haase
8个回答

20
当你在命令行中运行composer时,你很可能使用的不是XAMPP用于运行网站的PHP版本,这就是为什么它在此处报告缺少zip问题的原因。
最简单的解决方法是在安装期间忽略平台要求(在这种情况下是ext-zip), 运行 composer install --ignore-platform-reqs

12
请执行以下命令:
composer require phpoffice/phpspreadsheet
如果已经安装了`phpspreadsheet`,则需要将其版本升级到`composer.json`中的兼容版本。例如:将现有版本替换为:"phpoffice/phpspreadsheet": "^1.9",,并运行 composer update 更新。
要了解更多详情,请访问phpspreadsheet
还需通过 php -m 检查是否存在 `zip` 模块。如果找不到该模块,则需要安装它。你的错误信息表明它不存在于您的系统中。请参考此链接安装。

1
工作正常。需要重新安装带有 zip 扩展的 php cli。 - Neeraj
1
请分享更多细节。由于maatwebsite/excel需要该软件包,因此不需要手动要求它。如果缺少ZIP扩展名,则仍应无法要求需要此扩展名的任何软件包。 - Nico Haase

5

我也遇到了同样的问题,我在使用 Laravel 9。

尝试这个命令 composer require maatwebsite/excel --with-all-dependencies ,这可以解决问题。


"composer require maatwebsite/excel --with-all-dependencies",它对我有用,谢谢Oscar。 - ashish patel

4

"extension=gd"在php.ini中被注释了,你只需要将该行取消注释就可以解决问题!!!


phpoffice/phpspreadsheet 1.9.0 需要 ext-zip 扩展,启用 gd 扩展无法解决该问题。 - Nico Haase

4
如果上述解决方案无法解决问题,请使用以下方法。
Yajra/Datatables安装问题。phpoffice/phpspreadsheet 1.9.0需要ext-zip*,即您的系统缺少所请求的PHP扩展zip。
brew update
brew install php@7.3
brew link php@7.3 --force

2

我刚刚运行了以下命令,并且它对我起作用了。

由于我在我的Ubuntu系统上安装了PHP 7.3,所以我运行了这个命令。

sudo apt-get install php7.3-zip

1

首先,在php.ini文件中从;extension=gd中删除;。 然后,执行composer require psr/simple-cache ^2.0来更改您的缓存。

接下来安装maatwebsite/excel: composer require maatwebsite/excel


1
错误提示说明需要安装 phpoffice/phpspreadsheet ^ 1.6
请在 composer.json 文件中添加:
"require": {
        "phpoffice/phpspreadsheet": "^1.9"
    },

在命令提示符中运行以下命令:composer update

或者

要安装最新版本的phpoffice/phpspreadsheet,请运行以下命令

composer require phpoffice/phpspreadsheet

更多信息:phpoffice/phpspreadsheet | maatwebsite/excel


3
这个错误是因为缺少zip扩展引起的,原因是php cli版本没有安装该扩展。 - Neeraj
请分享更多细节。由于maatwebsite/excel需要该软件包,因此不需要手动要求它。如果缺少ZIP扩展名,则仍应无法要求需要此扩展名的任何软件包。 - Nico Haase

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接