【问题标题】:Setting up .yaml file for Google App Engine为 Google App Engine 设置 .yaml 文件
【发布时间】:2015-05-10 22:12:39
【问题描述】:

我似乎无法找到有关如何设置调用目录中其他 php 脚本的 .yaml 文件的有效答案。我对 .yaml 文件一无所知,并且没有很多简单的文档可以让我继续前进。这是我所拥有的:

handlers:
- url: /stylesheets
  static_dir: stylesheets
- url: /adminpanel
  script: pushnotifierv15.php
  secure: always
- url: /admin-services
  script: admin-services/notificationCP.php
- url: /sendMsg.php
  static_files: /admin-services/sendMsg.php
  upload: /admin-services/sendMsg.php

pushnotifierv15.php 与 .yaml 文件一起位于项目的根目录。所有其他脚本都在“admin-services”目录中。我不确定如何将其他脚本添加到 .yaml 文件中。 “notificationCP.php”是主脚本,其他脚本以它为食(通过表单提交)。 TIA 寻求帮助。

【问题讨论】:

    标签: php google-app-engine yaml


    【解决方案1】:

    您似乎缺少领先的/

    handlers:
    - url: /adminpanel
      script: pushnotifierv15.php
      secure: always
    - url: /admin-services
      script: /admin-services/notificationCP.php < add missing /
    

    参考:https://cloud.google.com/appengine/docs/php/config/appconfig#PHP_app_yaml_Script_handlers

    【讨论】:

    • 奇怪的是,这似乎没有什么区别。我同意它应该在那里,所以它已被添加。幸运的是,@Alex Martelli 的上述建议帮助了我。感谢您对我监督的帮助!
    【解决方案2】:

    您可以根据需要继续处理 url:/script: 对。例如,假设(因为我不知道您如何命名脚本或希望它们处理哪些 URL),您现在拥有的位置

    - url: /admin-services
      script: /admin-services/notificationCP.php
    - url: /sendMsg.php
      static_files: /admin-services/sendMsg.php
      upload: /admin-services/sendMsg.php
    

    你可以把它扩展成类似的东西

    - url: /admin-services
      script: /admin-services/notificationCP.php
    - url: /another-url
      script: /admin-services/whateverCP.php
    - url: /and-yet-another
      script: /admin-services/somethingelseCP.php
    - url: /sendMsg.php
      static_files: /admin-services/sendMsg.php
      upload: /admin-services/sendMsg.php
    

    等等。您还可以在url: 中使用正则表达式,让脚本为匹配正则表达式的多个 URL 提供服务(在这种情况下,请注意处理程序的顺序 - 作为一个极端示例,url: .*,如果存在,应该始终成为最后一个,因为它会匹配任何东西,并且不会考虑它下面的任何其他 URL - IOW,路由是通过尝试从上到下按顺序匹配 url: 指令来发生的)。

    【讨论】:

      猜你喜欢
      • 2012-11-19
      • 2015-12-08
      • 2019-04-06
      • 2019-05-24
      • 2015-02-10
      • 2019-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多