PHP 5 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、PHP 5 アプリケーションをデプロイできなくなります。既存の PHP 5 アプリケーションは、
非推奨になる日付以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの PHP に移行することをおすすめします。
php.ini ファイル
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
App Engine アプリケーションには php.ini ファイルをインクルードできます。このファイルにより、PHP インタープリタ ディレクティブの動作をカスタマイズできます。
php.ini について
php.ini
ファイルは、アプリケーションのベース ディレクトリ(app.yaml
ファイルと同じディレクトリ)に配置する必要があります。このファイルは、アプリケーション コードの実行前、PHP インタープリタが初期化されるときに読み込まれます。
このファイルは、他の .ini ファイルと同じ構文に従います。以下に簡単な例を示します。
; This is a simple php.ini file on App Engine
;
; This is a directive set to "On"
widget_compression = "On"
コア ディレクティブのリストとその変更可能なモード値は、php.net で公開されています。拡張機能によって処理される php.ini
ディレクティブは、拡張機能のそれぞれのページに記載されています。
次の変更可能なモード値のいずれかを持つ PHP ディレクティブは、オーバーライドできます。
PHP_INI_SYSTEM
PHP_INI_ALL
PHP_INI_PERDIR
一部の関数は、App Engine の PHP 実装で無効になっています。これらの関数を対象にするディレクティブに効果はありません。
extension
ディレクティブを使用すると、一連の動的に読み込み可能な拡張機能を有効にできます。
App Engine の PHP ディレクティブ
次のディレクティブは App Engine 環境に固有のもので、php.ini ファイルに含めることができます。
google_app_engine.enable_curl_lite
- 1 に設定すると、組み込みの cURL の App Engine 固有バージョンである cURL lite が有効になります。cURL lite は、標準の cURL 関数とほぼ同様に使用できますが、ソケットではなく URL 取得を内部で呼び出します。このため、URL 取得を使用しない場合と同様に機能し、CurlLiteMethodNotSupportedException
をスローします。注: アプリで curl.so 拡張機能と cURL lite を同時に有効にすることはできません。後者は cURL 関数をオーバーロードします。
google_app_engine.enable_functions
- App Engine でソフト無効化されている関数は、このディレクティブを使用して再度有効にできます。関数名をカンマ区切り文字列で表示します。google_app_engine.enable_functions = "phpversion, phpinfo"
google_app_engine.allow_include_gs_buckets
- Google Cloud Storage に保存されているファイルを使用して、include
または require
ステートメントをアプリケーションで使用可能にします。
注: デフォルトのバケットに #default#
を使用できます。この値は、ランタイムに現在のデフォルト バケット名に自動的に置き換えられます。
たとえば、デフォルトのバケットとともに、ファイルを含むバケット bucket_1
と bucket_2
をカンマ区切りの文字列で指定します。
google_app_engine.allow_include_gs_buckets = "#default#, bucket_1, bucket_2"
次のように、バケットとそれに含まれるファイルへのパスを指定することもできます。
google_app_engine.allow_include_gs_buckets = "bucket_1/path_x"
Google Cloud Storage から組み込まれるファイルが確認されるときに、指定したパスがファイル名の先頭に一致する接頭辞として扱われます。前述のパスの例では、指定したパスで gs://bucket_1/path_x/...
からのファイルを含めることができます。接頭辞は一致しますが、gs://bucket_1 or gs://bucket_1/path_y/
によるものではないケースや、接頭辞が一致しないなどのケースが考えられるからです。
アップロードしたファイルが許可されたバケットに移動すると、LFI 攻撃の可能性を知らせる警告がユーザーに表示されます。このような場合は、より制限の厳しいパスを使用する必要があります。
注: パスはファイル接頭辞として扱われます。したがって、特定のファイルを指定することもできます(例: google_app_engine.allow_include_gs_buckets = "bucket_1/path_x.ext", "bucket_2/path_z/some_file.ext
)。
google_app_engine.disable_readonly_filesystem
- デフォルトでは、PHP アプリケーションにはファイル システムへの書き込みが許可されていません。このディレクティブを 1 に設定すると、ローカル開発環境の制限が解除されます。この設定は、本番環境で実行されているアプリケーションには適用されません。これらのアプリケーションは常にサンドボックスの制限を受けます。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-04 UTC。
[[["わかりやすい","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 UTC。"],[[["\u003cp\u003eThe \u003ccode\u003ephp.ini\u003c/code\u003e file, placed in the base directory of an App Engine application, allows customization of PHP interpreter directives before application code execution.\u003c/p\u003e\n"],["\u003cp\u003eYou can override PHP directives with changeable mode values such as \u003ccode\u003ePHP_INI_SYSTEM\u003c/code\u003e, \u003ccode\u003ePHP_INI_ALL\u003c/code\u003e, and \u003ccode\u003ePHP_INI_PERDIR\u003c/code\u003e, excluding those targeting disabled functions.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine provides specific directives within \u003ccode\u003ephp.ini\u003c/code\u003e, including \u003ccode\u003egoogle_app_engine.enable_curl_lite\u003c/code\u003e to use "cURL lite," and \u003ccode\u003egoogle_app_engine.enable_functions\u003c/code\u003e to re-enable certain soft-disabled functions.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egoogle_app_engine.allow_include_gs_buckets\u003c/code\u003e directive permits the use of \u003ccode\u003einclude\u003c/code\u003e or \u003ccode\u003erequire\u003c/code\u003e statements with files stored in specified Google Cloud Storage buckets, with path prefix matching.\u003c/p\u003e\n"],["\u003cp\u003eIn local development, \u003ccode\u003egoogle_app_engine.disable_readonly_filesystem\u003c/code\u003e can be set to "1" to allow filesystem writing, but this is not applicable in production due to sandbox restrictions.\u003c/p\u003e\n"]]],[],null,["You can include a php.ini file with your App Engine application. This file\nlets you customize the behavior of the PHP interpreter directives.\n\nAbout php.ini\n\nThe `php.ini` file should be\nplaced in the base directory of an application (the same directory as the\n`app.yaml` file). It is loaded when the PHP interpreter is\ninitialized, and before your application code is run.\n\nThe file follows the same syntax as\n[other .ini files](https://en.wikipedia.org/wiki/INI_file). A simple\nexample might look like: \n\n```php\n; This is a simple php.ini file on App Engine\n;\n; This is a directive set to \"On\"\nwidget_compression = \"On\"\n```\n\nA list of the core directives, along with their changeable mode values,\n[is published on php.net](http://www.php.net/manual/en/ini.list.php).\nThe `php.ini` directives handled by extensions are documented on the\nrespective pages of the extensions themselves.\n\nYou may override any PHP directive that has one of the following changeable mode values:\n\n- `PHP_INI_SYSTEM`\n- `PHP_INI_ALL`\n- `PHP_INI_PERDIR`\n\nNote that some functions\n[have been\ndisabled in the App Engine implementation of PHP](/appengine/docs/legacy/standard/php/runtime#disabled_functions). Directives that target\nthese functions will have no effect.\n\nA set of [dynamically loadable extensions](/appengine/docs/legacy/standard/php/runtime#dynamically_loadable_extensions) can be enabled using the\n`extension` directive.\n\nPHP Directives for App Engine\n\nThe following directives are specific to the App Engine environment. They can\nbe included in the php.ini file.\n\n- **`google_app_engine.enable_curl_lite`** - Enables \"cURL lite\", a built-in, App Engine-specific version of cURL, when set to \"1\". \"cURL lite\" can be used exactly as you would use the standard [cURL functions](http://php.net/manual/en/ref.curl.php), but it calls [URL Fetch](/appengine/docs/legacy/standard/php/issue-requests) under the hood rather than sockets, thus functions with no URL Fetch equivalent, throw a `CurlLiteMethodNotSupportedException`.\n\n Note: An app can't enable the \"curl.so\" extension and \"cURL lite\" at the same time,\n as the latter overloads the cURL functions.\n- **`google_app_engine.enable_functions`** - Functions that have been [soft\n disabled](/appengine/docs/legacy/standard/php/runtime#functions_that_can_be_manually_enabled) in App Engine, but can be re-enabled using this directive. List the function names in a comma delimited string: \n\n ```\n google_app_engine.enable_functions = \"phpversion, phpinfo\"\n ```\n- **`google_app_engine.allow_include_gs_buckets`** - Allows your application to use the [`include`](http://php.net/manual/en/function.include.php) or [`require`](http://us1.php.net/manual/en/function.require.php) statements with files stored in [Google Cloud\n Storage](/appengine/docs/legacy/standard/php/googlestorage).\n\n \u003cbr /\u003e\n\n Note: You can use `#default#` for the default bucket; this value\n will be automatically replaced at runtime with your current default bucket name.\n\n For example, list the default bucket, along with buckets `bucket_1` and `bucket_2`\n containing the files in a comma delimited string: \n\n ```\n google_app_engine.allow_include_gs_buckets = \"#default#, bucket_1, bucket_2\"\n ```\n\n You can also specify a bucket and path to files that can be included, for example: \n\n ```\n google_app_engine.allow_include_gs_buckets = \"bucket_1/path_x\"\n ```\n\n When the check is performed for which files may be included from Google Cloud Storage, the\n supplied path is treated as a prefix that must match the start of the file name in order for it\n to be included or required. For example using the path example above, the supplied\n path would allow users to include files from `gs://bucket_1/path_x/...`\n because the prefix matches but not from `gs://bucket_1 or gs://bucket_1/path_y/` because\n the prefix doesn't match.\n\n If an uploaded file is moved to an allowed include bucket, a warning\n is generated to alert the user to a potential\n [LFI](https://en.wikipedia.org/wiki/File_inclusion_vulnerability)\n attack. If this happens, you should consider using a more\n restrictive path.\n\n **Note:** the path is treated as a file\n prefix; so it could include a specific file\n as well, for example, `google_app_engine.allow_include_gs_buckets = \"bucket_1/path_x.ext\", \"bucket_2/path_z/some_file.ext`.\n- **`google_app_engine.disable_readonly_filesystem`** - By default PHP applications are not allowed to write to the filesystem. Setting this directive to \"1\" will lift the restriction for the local development environment. However, the setting does not apply to applications running in production, which are always subjected to the [sandbox restrictions](/appengine/docs/legacy/standard/php/runtime#the_sandbox)."]]