A PHP App Engine application can be configured by a file named
app.yaml
that specifies how URL paths correspond to request handlers and static files.
It also contains information about the application code, such as the application ID and the latest version identifier.
Note: If you created your project using the Google Developers Console , your project has a title and an ID. In the instructions that follow, the project title and ID can be used wherever an application title and ID are mentioned. They are the same thing.
-
About
app.yaml
- Required elements
- Script handlers
- Static file handlers
- Secure URLs
- Requiring login or administrator status
- Skipping files
- Defining environment variables
- Reserved URLs
- Warmup requests
- Administration console custom pages
- Custom error responses
- Custom PageSpeed configuration
About
app.yaml
A PHP app specifies runtime configuration, including versions and URLs, in a file named
app.yaml
. The following is an example of an
app.yaml
file for a PHP application:
application: myapp version: 1 runtime: php api_version: 1 handlers: # Serve images as static resources. - url: /(.+\.(gif|png|jpg))$ static_files: \1 upload: .+\.(gif|png|jpg)$ application_readable: true # Serve php scripts. - url: /(.+\.php)$ script: \1
The above example will serve files with extension of
gif
,
png
, or
jpg
, i.e. images, as static resources. The files have been configured to be readable by the application code at runtime.
The example will also serve all PHP scripts. If desired, the script handler can be restricted to root-level scripts by using
url: /([^/]+\.php)
. Existing applications may find it useful to
simulate Apache mod_rewrite $_GET['q'] routing
.
A more extensive
app.yaml
example is provided below:
application: myapp version: 1 runtime: php api_version: 1 handlers: - url: / script: home.php - url: /index\.html script: home.php - url: /stylesheets static_dir: stylesheets - url: /(.*\.(gif|png|jpg))$ static_files: static/\1 upload: static/.*\.(gif|png|jpg)$ - url: /admin/.* script: admin.php login: admin - url: /.* script: not_found.php
The syntax of
app.yaml
is the YAML format. For more information about this syntax, see
the YAML website
.
The YAML format supports comments. A line that begins with a pound (
#
) character is ignored:
# This is a comment.
URL and file path patterns use
POSIX extended regular expression syntax
, excluding collating elements and collation classes. Back-references to grouped matches (e.g.
\1
) are supported, as are these Perl extensions:
\w \W \s \S \d \D