小编ElG*_*_76的帖子

Docker-compose:卷名太短,名称应至少为两个字母数字字符

我想创建一个 Apache 容器并将当前工作目录挂载为容器中的一个卷,所以我有这个代码:

volumes:
    - ${DOCUMENT_ROOT}:/var/www/html
Run Code Online (Sandbox Code Playgroud)

${DOCUMENT_ROOT} 的值是文件中的一个点.env

DOCUMENT_ROOT=.
Run Code Online (Sandbox Code Playgroud)

我的docker-compose.yml文件位于我的项目目录的根目录,在我的项目目录中有一个.docker目录。

我试过这 3 行:

volumes:
    - .:/var/www/html

volumes:
    - ./:/var/www/html

volumes:
    - ${DOCUMENT_ROOT}:/var/www/html
Run Code Online (Sandbox Code Playgroud)

但我有这个错误:

Creating 7.4.x-webserver ... error ERROR: for 7.4.x-webserver  Cannot
create container for service webserver: b'create .: volume name is too
short, names should be at least two alphanumeric characters'

ERROR: for webserver  Cannot create container for service webserver:
b'create .: volume name is too short, names should be at least two
alphanumeric …
Run Code Online (Sandbox Code Playgroud)

docker docker-compose

11
推荐指数
2
解决办法
2万
查看次数

wkhtmltopdf: QStandardPaths: XDG_RUNTIME_DIR 未设置,默认为 /tmp/runtime-root

我正在使用 Docker 映像php:8.0-fpm-alpine3.14,我有一个 Sylius 项目并且我想使用它wkhtmltopdf,所以我在 Dockerfile 中添加了这些行:

RUN apk --update --no-cache add \
   wkhtmltopdf \
    libgcc \
    libstdc++ \
    musl \
    qt5-qtbase \
    qt5-qtbase-x11 \
    qt5-qtsvg \
    qt5-qtwebkit \
    ttf-freefont \
    ttf-dejavu \
    ttf-droid \
    ttf-liberation \
    xvfb \
    fontconfig

# Add openssl dependencies for wkhtmltopdf
RUN echo 'https://dl-cdn.alpinelinux.org/alpine/v3.8/main' >> /etc/apk/repositories && \
    apk add --no-cache libcrypto1.0 libssl1.0

RUN ln -s /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf;
RUN chmod +x /usr/local/bin/wkhtmltopdf;
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用时出现此错误wkhtmltopdf

> 块引用

我不明白为什么会出现该错误以及如何解决该错误。

谢谢

php wkhtmltopdf docker sylius alpine-linux

9
推荐指数
0
解决办法
6061
查看次数

Docker:如何安装 PHP 7.4 扩展 ext-http?

我想安装ext-http扩展程序,因为在我的php-apache容器中执行 composer install 命令时出现此错误:

您的系统中缺少请求的 PHP 扩展 ext-http *。安装或启用 PHP 的 http 扩展。

我的 Dockerfile:

ARG PHP_VERSION=""

FROM php:${PHP_VERSION}-apache

ENV COMPOSER_ALLOW_SUPERUSER=1

EXPOSE 80
WORKDIR /${PROJECT_DIRECTORY}

# git, unzip & zip are for composer
RUN apt-get update -qq && \
    apt-get install -qy \
    git \
    gnupg \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libicu-dev \
    libxml2-dev \
    wget \
    nano \
    unzip \
    zip && \
    curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ …
Run Code Online (Sandbox Code Playgroud)

php docker dockerfile docker-compose

5
推荐指数
2
解决办法
1万
查看次数

Symfony - EasyAdmin - AssociationField 忽略添加和删除功能

我使用 EasyAdmin 的最新版本,当我提交表单时,我的add和函数将被忽略:remove

\n

Ambiance实体:

\n
/**\n * @ORM\\OneToMany(targetEntity="Vehicule", mappedBy="ambiance")\n */\nprotected Collection $vehicules;\n\npublic function __construct()\n{\n    $this->vehicules = new ArrayCollection();\n}\n\npublic function addVehicule(Vehicule $vehicule): self\n{\n    if (!$this->vehicules->contains($vehicule)) {\n        $this->vehicules[] = $vehicule;\n        $vehicule->setAmbiance($this);\n    }\n\n    return $this;\n}\n\npublic function removeVehicule(Vehicule $vehicule): void\n{\n    if (!$this->vehicules->contains($vehicule)) {\n        return;\n    }\n\n    $this->vehicules->removeElement($vehicule);\n}\n\npublic function getVehicules()\n{\n    return $this->vehicules;\n}\n\npublic function setVehicules($vehicules): void\n{\n    $this->vehicules = $vehicules;\n}\n
Run Code Online (Sandbox Code Playgroud)\n

然而我的学说映射是有效的..

\n

我的 EasyAdmin 表单位于AmbianceCrudController.php

\n
'vehicules' => AssociationField::new('vehicules', 'V\xc3\xa9hicules'),\n
Run Code Online (Sandbox Code Playgroud)\n

它会生成一个multiple select2,但是当我添加车辆并提交表单时,不会插入任何数据。

\n

php symfony doctrine-orm easyadmin easyadmin3

5
推荐指数
1
解决办法
657
查看次数

在学说中插入 json 不起作用

我调用了一个 JSON API,它将数据发回给我,我想使用 Symfony 中的 Doctrine 将此 JSON 插入到我的 MariaDB 数据库中。

我检索的 JSON 是一个对象数组,我在互联网上遵循了几个示例(例如:Doctrine array vs simple_array vs json_array)但没有一个有效,我不知道我的问题是什么。

这是我的代码:

    $client = new Client();
    $request = $client->request('GET', 'mylink.com');
    $response = $request->getBody();
    $livescore = json_decode($response, true);

    $array = [];
    foreach($livescore as $value) {
        if($value['match_hometeam_name'] === 'Lyon' || $value['match_awayteam_name'] === 'Lyon') {
            $array = $value;
            break;
        }
    }

    $livescoreObj = new Livescore();
    $livescoreObj->setDateRafraichissement(new \DateTime());
    $livescoreObj->setMatch($array);

    $this->entityManager->persist($livescoreObj);
    $this->entityManager->flush($livescoreObj);

    return new JsonResponse($array);
Run Code Online (Sandbox Code Playgroud)

我的实体:

    <?php

namespace SGBundle\Entity;
use Doctrine\ORM\Mapping as ORM;

/**
 * …
Run Code Online (Sandbox Code Playgroud)

php json doctrine symfony doctrine-orm

3
推荐指数
1
解决办法
6002
查看次数

使用 Redis 在 Symfony 5 中缓存 Doctrine 2 查询和结果

我想Redis 6.0.1在我的Symfony 5.0.8项目中使用来缓存Doctrine 2查询和结果。我尝试在添加包中cache.yamldoctrine.yaml添加包后为 Doctrine 配置 Redis predis/predis,但我不确定我的配置是否正确。

doctrine.yaml

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                dbname: '%env(DATABASE_NAME)%'
                user: '%env(DATABASE_USER)%'
                password: '%env(DATABASE_PASSWORD)%'
                host: '%env(DATABASE_HOST)%'
                driver:  '%env(DATABASE_DRIVER)%'
    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App

        metadata_cache_driver: ~

        query_cache_driver:
            type: pool
            id: doctrine.query_cache_pool

        result_cache_driver:
            type: pool
            id: doctrine.result_cache_pool
Run Code Online (Sandbox Code Playgroud)

cache.yaml

framework:
    cache:
        # Redis
        app: cache.adapter.redis
        default_redis_provider: redis://localhost
Run Code Online (Sandbox Code Playgroud)

您认为我的 Redis …

php redis symfony doctrine-orm

2
推荐指数
1
解决办法
3963
查看次数