Docker 运行 PHP-FPM 上的 symfony

Docker run symfony on PHP-FPM

如何将此 docker 图像上所有需要的 php 扩展安装到 运行 symfony 5。 目前无法运行 composer install cos 出现以下错误。

Problem 1 - Installation request for lorenzo/pinky 1.0.5 -> satisfiable by lorenzo/pinky[1.0.5]. - lorenzo/pinky 1.0.5 requires ext-xsl * -> the requested PHP extension xsl is missing from your system. Problem 2 - lorenzo/pinky 1.0.5 requires ext-xsl * -> the requested PHP extension xsl is missing from your system. - twig/inky-extra v3.0.5 requires lorenzo/pinky ^1.0.5 -> satisfiable by lorenzo/pinky[1.0.5]. - Installation request for twig/inky-extra v3.0.5 -> satisfiable by twig/inky-extra[v3.0.5].

我的 Dockerfile。

FROM php:7.4-fpm

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        nano \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

RUN curl --insecure https://getcomposer.org/download/1.10.19/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer

# Set timezone
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
RUN "date"

WORKDIR /var/www/symfony

我尝试将以下安装命令添加到 docker 文件“php7.4-xsl” 但后来我有以下错误:

E: Unable to locate package php7.4-xsl E: Couldn't find any package by glob 'php7.4-xsl' E: Couldn't find any package by regex 'php7.4-xsl'

composer.json

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": ">=7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-json": "*",
        "composer/package-versions-deprecated": "^1.11",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "2.1.2",
        "doctrine/doctrine-migrations-bundle": "^3.0",
        "doctrine/orm": "^2.7",
        "knpuniversity/oauth2-client-bundle": "^2.4",
        "league/html-to-markdown": "^4.10",
        "league/oauth2-google": "^3.0",
        "league/oauth2-linkedin": "^5.1",
        "phpdocumentor/reflection-docblock": "^5.2",
        "sensio/framework-extra-bundle": "^5.6",
        "symfony/asset": "5.1.*",
        "symfony/console": "5.1.*",
        "symfony/dotenv": "5.1.*",
        "symfony/expression-language": "5.1.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.1.*",
        "symfony/framework-bundle": "5.1.*",
        "symfony/http-client": "5.1.*",
        "symfony/intl": "5.1.*",
        "symfony/mailer": "5.1.*",
        "symfony/messenger": "5.1.*",
        "symfony/mime": "5.1.*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/notifier": "5.1.*",
        "symfony/process": "5.1.*",
        "symfony/property-access": "5.1.*",
        "symfony/property-info": "5.1.*",
        "symfony/security-bundle": "5.1.*",
        "symfony/serializer": "5.1.*",
        "symfony/string": "5.1.*",
        "symfony/translation": "5.1.*",
        "symfony/twig-bundle": "5.1.*",
        "symfony/validator": "5.1.*",
        "symfony/web-link": "5.1.*",
        "symfony/webpack-encore-bundle": "^1.7",
        "symfony/yaml": "5.1.*",
        "symfonycasts/verify-email-bundle": "^1.0",
        "twig/cssinliner-extra": "^3.0",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/inky-extra": "^3.0",
        "twig/twig": "^2.12|^3.0"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.3",
        "symfony/browser-kit": "^5.1",
        "symfony/css-selector": "^5.1",
        "symfony/debug-bundle": "^5.1",
        "symfony/maker-bundle": "^1.21",
        "symfony/phpunit-bridge": "^5.1",
        "symfony/stopwatch": "^5.1",
        "symfony/var-dumper": "^5.1",
        "symfony/web-profiler-bundle": "^5.1"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\Tests\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.1.*"
        }
    }
}

那么如何安装所有需要的模块?

谢谢

您需要手动安装所有需要的扩展。在您的情况下,您缺少 XSL 扩展名。这至少应该解决 XSL 问题。

FROM php:7.4-fpm

RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpng-dev \
        nano \
        libxslt1.1 \
        libxslt1-dev \
        unzip \
        git \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd xsl

RUN curl --insecure https://getcomposer.org/download/1.10.19/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer

# Set timezone
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
RUN "date"

WORKDIR /var/www/symfony

编辑:

我必须添加 git 并解压缩才能安装所有内容,但它确实有效。请确保您没有遗漏 docker-php-ext-install 语句中的 xsl