Jen Mason
Jen Mason

Reputation: 144

Setting up .yaml file for Google App Engine

I can't seem to find working answers to how to set up a .yaml file that calls other php scripts in the directory. I'm clueless on .yaml files and there isn't a lot of easy documentation out there to get me going. Here's what I have:

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, along with the .yaml file, is at the root of the project. All other scripts are in the "admin-services" directory. I'm not sure how to add the other scripts to the .yaml file. "notificationCP.php" is the main script and the other scripts feed off it (via form submits). TIA for any help.

Upvotes: 0

Views: 80

Answers (2)

marianosimone
marianosimone

Reputation: 3606

It seems like you are missing the leading /:

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

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

Upvotes: 1

Alex Martelli
Alex Martelli

Reputation: 882751

You can just keep handling url:/script: pairs as needed. For example, hypothetically (as I have no idea of how you've named your scripts or what URLs you want them to handle), where you now have

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

you could expand it to something like

- 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

and so forth. You can also use regular expressions in the url: to have a script serve multiple URLs matching a regex (in that case be careful about the order of your handlers -- as an extreme example, a url: .*, if present, should always be the last one, because it will match anything and no other URLs below it will ever be considered -- IOW, the routing happens by attempting to match the url: directives in order, from the top down).

Upvotes: 3

Related Questions