Can I run PHP files on Google App Engine for Python?

0 views
Skip to first unread message

jpdstan via StackOverflow

unread,
Mar 31, 2014, 9:23:43 PM3/31/14
to google-appengin...@googlegroups.com

As a disclaimer, I'm new to app development.

So I've been working on this website using Google App Engine with the Python Runtime Environment. Problems arose when I was creating a simple form in HTML and decided to use PHP to store the data. Am I allowed to use PHP scripts when my application is being run in Python?

I also noticed that GAE now has a PHP runtime environment, so should I use that instead? I only used Python because it was easy to use at first and I didn't think I needed PHP.

This is what my main.py looks like, if it matters:

import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template

class MainHandler(webapp.RequestHandler):
  def get (self, q):
    if q is None:
      q = 'index.html'

    path = os.path.join (os.path.dirname (__file__), q)
    self.response.headers ['Content-Type'] = 'text/html'
    self.response.out.write (template.render (path, {}))

def main ():
  application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
  util.run_wsgi_app (application)

if __name__ == '__main__':
  main ()


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/22775157/can-i-run-php-files-on-google-app-engine-for-python

mooddha via StackOverflow

unread,
Mar 31, 2014, 9:33:46 PM3/31/14
to google-appengin...@googlegroups.com

You can't use PHP and Python on the same GAE environment. But you could translate your PHP code to Python, and use Python to store your data, or you could use PHP fully.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/22775157/can-i-run-php-files-on-google-app-engine-for-python/22775203#22775203

Dan Sanderson via StackOverflow

unread,
Mar 31, 2014, 9:33:48 PM3/31/14
to google-appengin...@googlegroups.com

No, you will not be able to run PHP scripts in the Python runtime environment. If your application is more easily written in PHP, you can use the PHP runtime environment.

In app.yaml, set runtime: php, and create handlers: where the script: value is a PHP script:

applciation: helloworld
version: 1
runtime: php
api_version: 1

handlers:
- url: /.*
  script: helloworld.php

Then helloworld.php can be a PHP script, such as:

<?php
  echo 'Hello, world!';
?>

Note that you can use the same SDK for both Python and PHP.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/22775157/can-i-run-php-files-on-google-app-engine-for-python/22775232#22775232

mooddha via StackOverflow

unread,
Mar 31, 2014, 9:38:40 PM3/31/14
to google-appengin...@googlegroups.com

You can't use PHP and Python on the same GAE environment. But you could translate your PHP code to Python, and use Python to store your data, or you could use PHP fully.

Take note that PHP is currently experimental:

The PHP runtime is available as an experimental Preview feature. Please be aware that the APIs and service may change before the service becomes Generally Available.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/22775157/can-i-run-php-files-on-google-app-engine-for-python/22775203#22775203
Reply all
Reply to author
Forward
0 new messages