我被这些错误困扰了好几天,并且我已经尝试了很多Dockerfile配置。
版本号

  • PHP版本:7.3
  • Laravel版本:^ 6.2
  • 软件包版本:^ 3.1

  • 描述
    确切错误
      Problem 1
        - Installation request for phpoffice/phpspreadsheet 1.11.0 -> satisfiable by phpoffice/phpspreadsheet[1.11.0].
        - phpoffice/phpspreadsheet 1.11.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
      Problem 2
        - phpoffice/phpspreadsheet 1.11.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
        - maatwebsite/excel 3.1.19 requires phpoffice/phpspreadsheet ^1.10 -> satisfiable by phpoffice/phpspreadsheet[1.11.0].
        - Installation request for maatwebsite/excel 3.1.19 -> satisfiable by maatwebsite/excel[3.1.19].
    
      To enable extensions, verify that they are enabled in your .ini files:
        -
        - /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini
        - /usr/local/etc/php/conf.d/docker-php-ext-exif.ini
        - /usr/local/etc/php/conf.d/docker-php-ext-gd.ini
        - /usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini
        - /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
        - /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
      You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
    
    我的Dockerfile
    FROM php:7.3-fpm
    
    # Arguments defined in docker-compose.yml
    ARG user
    ARG uid
    
    # Install system dependencies
    RUN apt-get update && apt-get install -y \
        git \
        curl \
        libpng-dev \
        libonig-dev \
        libxml2-dev
    
    RUN apt-get update && \
         apt-get install -y \
             libzip-dev \
             && docker-php-ext-install zip
    
    # Clear cache
    RUN apt-get clean && rm -rf /var/lib/apt/lists/*
    
    # Install PHP extensions
    RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
    
    # Get latest Composer
    COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
    
    # Create system user to run Composer and Artisan Commands
    RUN useradd -G www-data,root -u $uid -d /home/$user $user
    RUN mkdir -p /home/$user/.composer && \
        chown -R $user:$user /home/$user
    
    # Set working directory
    WORKDIR /var/www
    
    USER $user
    
    # Run migration?
    
    

    最佳答案

    以我的经验,有时安装php扩展名是如此令人困惑。
    幸运的是,有一个很棒的存储库(docker-php-extension-installer)可以轻松完成:

    COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
    
    RUN install-php-extensions zip
    
    您也可以添加任何扩展名,而不必考虑依赖项。

    关于laravel - 我如何在Docker环境中使用它-缺少ext-zip扩展名,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62592058/

    10-16 09:49