0

我正在尝试将我的新 Laravel 项目部署到 Google App Engine,但是它没有说“PHP extension bcmath is missing”。我使用Laradock,所以我可以让我的项目在 Docker 容器中运行。

以下是 Google Cloud 日志的结尾:

Step #1: INFO[0000] Removing ignored files from build context: [.dockerignore Dockerfile .git .hg .svn *~ .\#* app.yaml] 
Step #1: INFO[0001] Downloading base image gcr.io/google-appengine/php72@sha256:0f0d6c07035fd5138d917b4d539f4473ca13528f11c26c92be54b9e33c0f722b 
Step #1: INFO[0013] Taking snapshot of full filesystem... 
Step #1: INFO[0020] ENV DOCUMENT_ROOT='/app/public' APP_LOG='errorlog' APP_KEY='base64:ak4/ZLdvSpRF3JDRPuR8mgzzGB8GXGuLVF/PP8qnTH4=' STORAGE_DIR='/tmp' FRONT_CONTROLLER_FILE='index.php' COMPOSER_FLAGS='--no-dev --prefer-dist' DETECTED_PHP_VERSION='7.2' 
Step #1: INFO[0020] Using files from context: [/workspace] 
Step #1: INFO[0020] COPY . $APP_DIR 
Step #1: INFO[0022] Taking snapshot of files... 
Step #1: INFO[0024] RUN chown -R www-data.www-data $APP_DIR 
Step #1: INFO[0024] cmd: /bin/sh 
Step #1: INFO[0024] args: [-c chown -R www-data.www-data $APP_DIR] 
Step #1: INFO[0024] Taking snapshot of full filesystem... 
Step #1: INFO[0032] RUN /build-scripts/composer.sh 
Step #1: INFO[0032] cmd: /bin/sh 
Step #1: INFO[0032] args: [-c /build-scripts/composer.sh] 
Step #1: Using PHP version: 7.2
Step #1: Install PHP extensions...
Step #1: Running composer...
Step #1: Loading composer repositories with package information
Step #1: Installing dependencies from lock file
Step #1: Your requirements could not be resolved to an installable set of packages.
Step #1: 
Step #1: Problem 1
Step #1: - Installation request for moontoast/math 1.1.2 -> satisfiable by moontoast/math[1.1.2].
Step #1: - moontoast/math 1.1.2 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
Step #1: Problem 2
Step #1: - moontoast/math 1.1.2 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
Step #1: - laravel/telescope v1.0.10 requires moontoast/math ^1.1 -> satisfiable by moontoast/math[1.1.2].
Step #1: - Installation request for laravel/telescope v1.0.10 -> satisfiable by laravel/telescope[v1.0.10].
Step #1: 
Step #1: To enable extensions, verify that they are enabled in your .ini files:
Step #1: - /opt/php72/lib/php-cli.ini
Step #1: - /opt/php72/lib/ext.enabled/ext-apcu-bc.ini
Step #1: - /opt/php72/lib/ext.enabled/ext-mailparse.ini
Step #1: - /opt/php72/lib/ext.enabled/ext-memcached.ini
Step #1: You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Step #1: error building image: error building stage: waiting for process to exit: exit status 2
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/kaniko-project/executor@sha256:f87c11770a4d3ed33436508d206c584812cd656e6ed08eda1cff5c1ee44f5870" failed: exit status 1

我尝试将 Laradock 的主 php.ini 复制到根项目文件夹,但这没有帮助。希望有人可以帮助我。

4

1 回答 1

3

出色地。在尝试了一堆不同的东西几个小时后,我清空了脑袋,重新坐下,从头开始。那时我才意识到我是多么愚蠢。

无论如何,扩展 bcmath 丢失了。我想我在某处读到,默认情况下,bcmath 扩展在 Google App Engine 的 PHP 运行时中是打开的。此情况并非如此。

因此,在慢慢阅读此https://cloud.google.com/appengine/docs/flexible/php/runtime之后,我发现我需要做的就是在我的 composer.json 中启用 bcmath 扩展,因为 Google Cloud 从这个文件中读取.

"name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/telescope": "^1.0",
        "laravel/tinker": "^1.0",
        "ext-bcmath": "*"
    },

我添加了“ext-bcmath”,部署了应用程序并且它工作了!

于 2019-01-15T12:42:56.167 回答