Issues Getting PHP to work with app.yaml and Google App Engine

447 views Asked by At

I've launched an HTML site that works just fine on GAE but I am struggling when it comes to activating and integrating my PHP code. I know it is likely because of my app.yaml contruction. I followed other recommendations to simplify the app.yaml file at first. I researched others who fully list off all the scripts and files needed within the app.yaml and tried this approach with no luck.

Here is my current app.yaml:

application: safe
version: 1
runtime: php
api_version: 1
threadsafe: true

handlers:
- url: /
  static_files: static/index.html
  upload: static/index.html
- url: /
  static_dir: static/

My directory of files looks like this:

https://i.stack.imgur.com/pjw8S.jpg

The index.html resides within the static dir and within it, there is a contact form that calls a PHP file within the contact-form directory.

Is there a simple way to fix the app.yaml? Can I add only the PHP file as a script directive within the app.yaml without listing everything? Is there anything else I need to do to get the PHP code to work?

Thanks, Chris

1

There are 1 answers

3
boombatower On

You shouldn't need both handlers as they overlap since the first handles just index.html and second handles everything in static/ which includes index.html.

Also note that everything does not have to be placed in a directory named static. If you choose to keep that it may still make sense to move PHP outside of that since it is not static, but ignoring that the following will serve any php files in contact-form from the URL path /contact-form/...

- url: /contact-form/(.+\.php)
  script: static/contact-form/\1

You could also do something that works for all php files like.

- url: /(.+\.php)
  script: static/\1

Or if you move out of static directory:

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