使用docker运行创建webman后,运行php start.php start 报错

oceansu

使用docker运行创建webman后,运行php start.php start 报错

程序代码

# 最小镜像
FROM php:8.3.14-cli-alpine
LABEL MAINTAINER="oceansu"
# 设置镜像源(科大)并且更新
# 设置为调试模式
RUN set -x && \
        sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
        apk update && \
        apk upgrade
# 设置时区
RUN apk add --no-cache tzdata && \ 
        cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
    # 设置为上海时区
        echo "Asia/Shanghai" > /etc/timezone && \
    # 查看时区
        date -R
# 下载必要的包(--no-cache下载完成后清除缓存,在容器内是很有必要的)
# 找不到去alpine-linux package查找
RUN apk add --no-cache \
        bash \
        curl \
        zip \
        unzip
# 本地下载安装器
COPY ./install-php-extensions /usr/local/bin/install-php-extensions
# 安装扩展安装器
RUN chmod +x /usr/local/bin/install-php-extensions && \
    install-php-extensions pcntl posix
# 安装composer(使用阿里云镜像)
RUN curl https://mirrors.aliyun.com/composer/composer.phar -o composer.phar && \
        chmod +x composer.phar && \
        mv composer.phar /usr/local/bin/composer && \
    # 换源
        composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ && \
        mkdir www && cd www/
# 设置主目录
WORKDIR /www
# 暴露端口
EXPOSE 8787
# 必须加上"/bin/sh", "-l", "-c" Docker 运行的默认 shell 不是登录 shell,这意味着 /etc/profile.d/ 中的脚本不会被处理。
# ENTRYPOINT ["/bin/sh", "-l", "-c","php start.php start"]
CMD [ "/bin/sh" ]

之后执行

composer create-project workerman/webman
cd ./webman && php start.php start

报错信息

Fatal error: Declaration of Webman\Http\Request::file($name = null) must be compatible with Workerman\Protocols\Http\Request::file(?string $name = null): mixed in /www/webman/vendor/workerman/webman-framework/src/Http/Request.php on line 119
Worker[520] process terminated with ERROR: E_COMPILE_ERROR "Declaration of Webman\Http\Request::file($name = null) must be compatible with Workerman\Protocols\Http\Request::file(?string $name = null): mixed in /www/webman/vendor/workerman/webman-framework/src/Http/Request.php on line 119"
78 1 0
1个回答

composer代理有问题,把composer代理删了,重新安装

×
🔝