php - 带有 Laravel Excel : Your requirements could not be resolved to an installable set of packages 的 Laravel 7

标签 php laravel docker laravel-excel

我正在尝试安装 Laravel Excel 拉雷维尔 7 中运行Docker 容器 PHP 7.4 但我收到这个错误,我不知道如何解决。

e-learning-app/src on  dev [$!] via ⬢ v12.8.1 via 🐘 v7.4.4
➜ docker:composer require maatwebsite/excel
Starting e-learning-app-php ... done
Using version ^3.1 for maatwebsite/excel
./composer.json has been updated
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.x-dev requires phpoffice/phpspreadsheet ^1.11 -> satisfiable by phpoffice/phpspreadsheet[1.11.0, 1.12.0, 1.13.0].
    - maatwebsite/excel 3.2.x-dev requires phpoffice/phpspreadsheet ^1.11 -> satisfiable by phpoffice/phpspreadsheet[1.11.0, 1.12.0, 1.13.0].
    - maatwebsite/excel 3.1.0 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.18 requires phpoffice/phpspreadsheet ^1.10 -> satisfiable by phpoffice/phpspreadsheet[1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0].
    - maatwebsite/excel 3.1.19 requires phpoffice/phpspreadsheet ^1.10 -> satisfiable by phpoffice/phpspreadsheet[1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0].
    - maatwebsite/excel 3.1.2 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.7 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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.10.0, 1.10.1, 1.11.0, 1.12.0, 1.13.0, 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-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.8.2 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.8.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.8.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.7.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.6.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.5.2 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.5.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.5.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.4.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.4.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.13.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.12.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.11.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.10.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - phpoffice/phpspreadsheet 1.10.0 requires ext-gd * -> the requested PHP extension gd 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.18, 3.1.19, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.1.x-dev, 3.2.x-dev].

  To enable extensions, verify that they are enabled in your .ini files:
    - /usr/local/etc/php/php-cli.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-zip.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.

e-learning-app/src on  dev [$!] via ⬢ v12.8.1 via 🐘 v7.4.4 took 3m 1s
➜

我已经安装了 gd 通过运行手动在容器内:
apt-get update && apt-get install -y --no-install-recommends \
build-essential \
zlib1g-dev \
libpng-dev \
&& docker-php-ext-configure gd --enable-gd && docker-php-ext-install -j$(nproc) gd

但问题依旧, gd 当我这样做时似乎已安装 php -m :
# php -m
[PHP Modules]
Core
curl
pdo_mysql
...
zlib
gd

[Zend Modules]

#

但是当我这样做时 composer show -p通过我的 Composer 容器, gd 扩展没有出现:
e-learning-app on  dev [$!?] on 🐳 v19.03.8 took 1h 10s
➜ docker:composer show -p
Starting e-learning-app-php ... done
composer-plugin-api  1.1.0    The Composer Plugin API
composer-runtime-api 1.0.0    The Composer Runtime API
ext-ctype            7.4.6    The ctype PHP extension
ext-curl             7.4.6    The curl PHP extension
ext-date             7.4.6    The date PHP extension
ext-dom              20031129 The dom PHP extension
ext-fileinfo         7.4.6    The fileinfo PHP extension
ext-filter           7.4.6    The filter PHP extension
ext-ftp              7.4.6    The ftp PHP extension
ext-hash             7.4.6    The hash PHP extension
ext-iconv            7.4.6    The iconv PHP extension
ext-json             7.4.6    The json PHP extension
ext-libxml           7.4.6    The libxml PHP extension
ext-mbstring         7.4.6    The mbstring PHP extension
ext-mysqlnd          0        The mysqlnd PHP extension (actual version: mysqlnd 7.4.6)
ext-openssl          7.4.6    The openssl PHP extension
ext-pcre             7.4.6    The pcre PHP extension
ext-PDO              7.4.6    The PDO PHP extension
ext-pdo_sqlite       7.4.6    The pdo_sqlite PHP extension
ext-Phar             7.4.6    The Phar PHP extension
ext-posix            7.4.6    The posix PHP extension
ext-readline         7.4.6    The readline PHP extension
ext-Reflection       7.4.6    The Reflection PHP extension
ext-session          7.4.6    The session PHP extension
ext-SimpleXML        7.4.6    The SimpleXML PHP extension
ext-sodium           7.4.6    The sodium PHP extension
ext-SPL              7.4.6    The SPL PHP extension
ext-sqlite3          7.4.6    The sqlite3 PHP extension
ext-tokenizer        7.4.6    The tokenizer PHP extension
ext-xml              7.4.6    The xml PHP extension
ext-xmlreader        7.4.6    The xmlreader PHP extension
ext-xmlwriter        7.4.6    The xmlwriter PHP extension
ext-zip              1.15.6   The zip PHP extension
ext-zlib             7.4.6    The zlib PHP extension
lib-curl             7.67.0   The curl PHP library
lib-libxml           2.9.10   The libxml PHP library
lib-openssl          1.1.1.7  OpenSSL 1.1.1g  21 Apr 2020
lib-pcre             10.34    The pcre PHP library
php                  7.4.6    The PHP interpreter
php-64bit            7.4.6    The PHP interpreter, 64bit
php-ipv6             7.4.6    The PHP interpreter, with IPv6 support

我不知道为什么会这样。我尝试了很多事情都没有成功......

这是我的 Dockerfile用于 PHP
FROM php:7.4-fpm

WORKDIR /var/www/html

RUN docker-php-ext-install pdo_mysql

这是我的 docker-compose.yml 中的 php 部分:
  php:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: e-learning-app-php
    volumes:
      - ./src:/var/www/html
    ports:
      - "9007:9000"
    networks:
      - laravel

还有我的 Composer 部分:
composer:
    image: composer:latest
    container_name: e-learning-app-composer
    volumes:
      - ./src:/var/www/html
    working_dir: /var/www/html
    depends_on:
      - php
    networks:
      - laravel

帮助。

最佳答案

Composer 需要 maatwebsite/excel --ignore-platform-reqs
试试这个。这对我来说很好用

关于php - 带有 Laravel Excel : Your requirements could not be resolved to an installable set of packages 的 Laravel 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62420521/

相关文章:

php - SQL仅在两个用户之间检索结果

docker - 为什么 udev init 脚本默认禁用容器支持,而实际上它可以工作?

asp.net - 在 docker 中安装 .net framework 4.7.2

docker - 本地 Laradock Nginx 项目上的 SSL 证书

php - 我无法在实时服务器上的 mysql phpmyadmin 中导入 450 .sql.zip 文件

php - foreach 循环,在 foreach 循环中使用 sql 查询

php - 在 WooCommerce 中,在所有订单的运输详细信息下添加新的输入字段,仅向管理员显示

php - 从 php 调用谷歌分析方法 _trackEvent()

laravel - 从同一个 Controller 管理 View 和 api

Laravel 5.5 测试 - 调用未定义的方法::see()