當 Google 宣布要支援執行階段環境中 API 的新版本時,已部署的應用程式還是會繼續使用已編寫在設定檔中的 API 版本。如要將應用程式升級來使用新的 API 版本,請變更這個值,然後將應用程式重新部署至 App Engine。如果您將這個值指定為 1,每當您部署該應用程式時,系統就會使用受支援的最新執行階段環境 (目前為 )。
目前 App Engine 有一個版本的 php 執行階段環境:1
default_expiration
(非必要) 會針對應用程式的所有靜態檔案處理常式,設定全域的預設快取有效期限。您也可以設定特定靜態檔案處理常式的快取效期。這個值是由數字和單位 (以空格分隔) 組成的字串,其中單位可為 d (天數)、h (小時數)、m (分鐘數) 和 s (秒數)。舉例來說,"4d 5h" 會將快取有效期限設定為檔案首次收到要求後的 4 天又 5 小時。如果您省略這個值,實際工作環境伺服器會把有效期限設定為 10 分鐘。
handlers:# All URLs beginning with /stylesheets are treated as paths to# static files in the stylesheets/ directory.-url:/stylesheetsstatic_dir:stylesheets# ...
handlers:# All URLs ending in .gif .png or .jpg are treated as paths to# static files in the static/ directory. The URL pattern is a# regular expression, with a grouping that is inserted into the# path to the file.-url:/(.*\.(gif|png|jpg))$static_files:static/\1upload:static/.*\.(gif|png|jpg)$# ...
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eThe \u003ccode\u003eapp.yaml\u003c/code\u003e file is essential for configuring App Engine applications, defining settings, URL paths, request handlers, and static files, with each service having its own configuration file.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eregion ID\u003c/code\u003e is a code assigned by Google based on the selected region during app creation and is included in App Engine URLs for applications made after February 2020.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eapp.yaml\u003c/code\u003e uses YAML format, allows comments with \u003ccode\u003e#\u003c/code\u003e, and utilizes POSIX extended regular expressions for URL and file path patterns.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ehandlers\u003c/code\u003e section in \u003ccode\u003eapp.yaml\u003c/code\u003e defines how the application handles different URLs, specifying elements like \u003ccode\u003escript\u003c/code\u003e, \u003ccode\u003estatic_files\u003c/code\u003e, \u003ccode\u003eurl\u003c/code\u003e, \u003ccode\u003esecure\u003c/code\u003e, \u003ccode\u003eredirect_http_response_code\u003c/code\u003e and \u003ccode\u003ehttp_headers\u003c/code\u003e, among other attributes.\u003c/p\u003e\n"],["\u003cp\u003eScaling elements such as \u003ccode\u003eautomatic_scaling\u003c/code\u003e, \u003ccode\u003ebasic_scaling\u003c/code\u003e, and \u003ccode\u003emanual_scaling\u003c/code\u003e control how App Engine manages instance counts based on traffic and resource usage, affecting performance and cost.\u003c/p\u003e\n"]]],[],null,["# App Engine app.yaml reference\n\n### Region ID\n\nThe \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e is an abbreviated code that Google assigns\nbased on the region you select when you create your app. The code does not\ncorrespond to a country or province, even though some region IDs may appear\nsimilar to commonly used country and province codes. For apps created after\nFebruary 2020, \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e`.r` is included in\nApp Engine URLs. For existing apps created before this date, the\nregion ID is optional in the URL.\n\nLearn more\n[about region IDs](/appengine/docs/legacy/standard/php/how-requests-are-routed#region-id). \nOK\n\n\u003cbr /\u003e\n\nYou configure your App Engine app's settings in the `app.yaml`\nfile.\n\nThis file specifies how URL paths correspond to request handlers and\nstatic files.\n\nThe `app.yaml` file also contains information about your\napp's code, such as the runtime and the latest version\nidentifier.\n\nEach [service](/appengine/docs/legacy/standard/php/an-overview-of-app-engine#services)\nin your app has its own `app.yaml` file, which acts as a descriptor for its\ndeployment. You must first create the `app.yaml` file for the `default` service\nbefore you can create and deploy `app.yaml` files for additional services within\nyour app.\n\n\u003cbr /\u003e\n\nDirectory structure\n-------------------\n\nTo learn more about structuring multiple services in your app, see [Structuring Web Services in App Engine](/appengine/docs/legacy/standard/php/configuration-files).\n\n\u003cbr /\u003e\n\nExample\n-------\n\nThe following is an example of an `app.yaml` file for a PHP 5\napplication:\n\n\u003cbr /\u003e\n\n```yaml\nruntime: php55\napi_version: 1\n\nhandlers:\n# Serve images as static resources.\n- url: /(.+\\.(gif|png|jpg))$\n static_files: \\1\n upload: .+\\.(gif|png|jpg)$\n application_readable: true\n\n# Serve php scripts.\n- url: /(.+\\.php)$\n script: \\1\n```\n\nThe above example will serve files with extension of `gif`, `png`, or `jpg` as\nstatic resources. The files have been configured to be readable by the\napplication code at runtime.\n\nThe example will also serve all PHP scripts. You can restrict the script handler\nto root-level scripts by using the `url: /([^/]+\\.php)` expression. Existing\napplications might find it useful to [simulate Apache mod_rewrite `$_GET['q']`\nrouting](/appengine/docs/legacy/standard/php/config/mod_rewrite).\n\nA more extensive `app.yaml` configuration is provided below: \n\n```yaml\nruntime: php55\napi_version: 1\n\nhandlers:\n- url: /\n script: home.php\n\n- url: /index\\.html\n script: home.php\n\n- url: /stylesheets\n static_dir: stylesheets\n\n- url: /(.*\\.(gif|png|jpg))$\n static_files: static/\\1\n upload: static/.*\\.(gif|png|jpg)$\n\n- url: /admin/.*\n script: admin.php\n login: admin\n\n- url: /.*\n script: not_found.php\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nSyntax\n------\n\nThe syntax of `app.yaml` is the [YAML format](http://www.yaml.org/).\n\nThe YAML format supports comments. A line that begins with a pound (`#`)\ncharacter is ignored: \n\n # This is a comment.\n\nURL and file path patterns use [POSIX extended regular expression\nsyntax](https://wikipedia.org/wiki/Regular_expression), excluding collating\nelements and collation classes. Back-references to grouped matches (e.g. `\\1`)\nare supported, as are these Perl extensions: `\\w \\W \\s \\S \\d \\D`.\n\n### Runtime and app elements\n\n### Handlers element\n\nThe `handlers` element is a required element in the\n`app.yaml` configuration file. The element provides a list of URL\npatterns and descriptions of how they should be handled. App Engine can\nhandle URLs by executing application code, or by serving static files uploaded\nwith the code, such as images, CSS, or JavaScript.\n\nPatterns are evaluated in the order they appear in the `app.yaml` file, from\ntop to bottom. The first mapping whose pattern matches the URL is the one used\nto handle the request.\n\nThe following table lists the subelements of the `handlers` element that control\nthe behavior for scripts, static files,\nstatic directories, and other settings.\n\n### Scaling elements\n\nThe elements in following table configure how your application scales. To learn\nmore about how App Engine apps scale, see\n[Scaling types](/appengine/docs/legacy/standard/php/how-instances-are-managed#scaling_types)."]]