gpt4 book ai didi

laravel - 我如何让它在 docker 环境中工作 - 缺少 ext-zip 扩展

转载 作者:行者123 更新时间:2023-12-02 19:47:53 25 4
gpt4 key购买 nike

我被这些错误困扰了好几天,我尝试了很多 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com