Google App Engine
Feedback on this document

Hello, World!

Let's begin by implementing a tiny application that displays a short message.

Creating a Simple Script

Create a directory named helloworld. All files for this application reside in this directory.

Inside the helloworld directory, create a file named helloworld.php, and give it the following contents:

<?php
  echo 'Hello, World!';

This PHP script responds to all requests with the message Hello, world!.

Creating the Configuration File

An App Engine application has a configuration file called app.yaml. Among other things, this file describes which handler scripts should be used for which URLs.

Inside the helloworld directory, create a file named app.yaml with the following contents:

application: helloworld
version: 1
runtime: php
api_version: 1

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

From top to bottom, this configuration file says the following about this application:

  • The application identifier is helloworld. Every new application on App Engine has a unique application identifier. You'll choose the identifier for your application when you register it in the next step. Until then you can just leave the value here set to helloworld because this value is not important when developing locally.
  • This is version number 1 of this application's code. If you adjust this before uploading new versions of your application software, App Engine will retain previous versions, and let you roll back to a previous version using the administrative console.
  • This code runs in the php runtime environment, version "1". Additional runtime environments and languages may be supported in the future.
  • Every request to a URL whose path matches the regular expression /.* (all URLs) should be handled by the helloworld.php script.

The syntax of this file is YAML. For a complete list of configuration options, see the app.yaml reference.

Testing the Application

With a handler script and configuration file mapping every URL to the handler, the application is complete. You can now test it with the web server included with the App Engine SDK.

Start the web server with the following command, giving it the path to the helloworld directory:

google_appengine/dev_appserver.py helloworld/

The web server is now running, listening for requests on port 8080. You can test the application by visiting the following URL in your web browser:

For more information about running the development web server, including how to change which port it uses, see the Dev Web Server reference, or run the command with the option --help.

Next...

You now have a complete App Engine application! You could deploy this simple greeting right now and share it with users worldwide. But before we deploy it, let's take a closer look some more interesting App Engine features.

Continue to Using the Users Service.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.