【问题标题】:Update app.yaml when updating php55 to php74 in Google App Engine在 Google App Engine 中将 php55 更新为 php74 时更新 app.yaml
【发布时间】:2021-07-11 02:21:03
【问题描述】:

目前我的 Google App Engine 项目正在使用php55,但由于社区不再支持此版本,我需要更新app.yaml 文件以使用php74 runtime

这些是app.yaml 文件中php55 的当前 URL 处理程序:

- url: /([^/]+\.php)
  script: \1

- url: /.*
  script: index.php
  login: required
  secure: always

当我指定 php74 运行时时,这些 URL 处理程序会引发错误:

INVALID_ARGUMENT: script field for handler '/([^/]+\.php)' must be set to 'auto' for runtime php74.
INVALID_ARGUMENT: script field for handler '/.*' must be set to 'auto' for runtime php74.

当我进行建议的修复并更改 app.yamlfor php74 中的 URL 处理程序时:

- url: /([^/]+\.php)
  script: auto

- url: /.*
  script: auto
  login: required
  secure: always

这会返回以下错误:ResourceNotFoundException: No routes found...

我在使用这些 URL 处理程序时做错了什么?我的项目适用于 URL 处理程序的 php55 版本,但当我在 php74 版本的 app.yaml 文件中指定 script: auto 时却不能。

【问题讨论】:

    标签: google-app-engine google-cloud-platform app.yaml


    【解决方案1】:

    根据documentation,要正确迁移您的app.yaml,您必须放置一个front controller 来处理所有路由。如果您从旧版应用程序迁移,以下是文档提供的示例:

    switch (@parse_url($_SERVER['REQUEST_URI'])['path']) {
        case '/':
            require 'homepage.php';
            break;
        case '/contact.php':
            require 'contact.php';
            break;
        default:
            http_response_code(404);
            exit('Not Found');
    }
    

    另外我建议你检查一下你的 app.yaml 中没有使用不推荐使用的元素,如果你使用任何会出现错误。 最后,如果其中任何方法有效,我建议您检查 this 以查看您的 app.yaml 是否有任何您没有注意到的问题。

    【讨论】:

    • 感谢@drauedo,您确实是正确的。问题是我需要使用前端控制器来处理所有路由。
    猜你喜欢
    • 1970-01-01
    • 2013-05-07
    • 2013-11-08
    • 2014-05-21
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 2021-10-19
    • 1970-01-01
    相关资源
    最近更新 更多