Fichier php.ini
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Vous pouvez inclure un fichier php.ini à votre application App Engine. Ce fichier vous permet de personnaliser le comportement des directives de l'interpréteur PHP.
À propos de php.ini
Le fichier php.ini
doit être placé dans le répertoire de base d'une application (le même répertoire que le fichier app.yaml
). Il est chargé lors de l'initialisation de l'interpréteur PHP et avant l'exécution du code de l'application.
Le fichier suit la même syntaxe que les autres fichiers .ini. Un exemple simple pourrait ressembler à ceci :
; This is a simple php.ini file on App Engine
;
; This is a directive set to "On"
widget_compression = "On"
Une liste des directives principales, avec leurs valeurs en mode variable, est publiée sur php.net. Les directives php.ini
gérées par des extensions sont répertoriées sur les pages de chaque extension.
Vous pouvez remplacer toute directive PHP ayant l'une des valeurs en mode variable suivantes :
PHP_INI_SYSTEM
PHP_INI_ALL
PHP_INI_PERDIR
Notez que certaines fonctions ont été désactivées dans la mise en œuvre App Engine de PHP. Les directives qui ciblent ces fonctions n'auront aucun effet.
La directive extension
vous permet d'activer un ensemble d'extensions pouvant être chargées dynamiquement.
Directives PHP pour App Engine
Les directives suivantes sont spécifiques à l'environnement App Engine. Elles peuvent être incluses dans le fichier php.ini.
google_app_engine.enable_curl_lite
: Active "cURL lite", une version intégrée de cURL spécifique à App Engine, lorsqu'elle est définie sur "1".
La version "cURL lite" peut être utilisée exactement de la même manière que les fonctions standards de cURL, mais elle utilise, en coulisses, URL Fetch plutôt que des sockets. Ainsi les fonctions sans équivalent d'"URL Fetch" génèrent une exception CurlLiteMethodNotSupportedException
.
Remarque : Une application ne peut pas activer simultanément les extensions "curl.so" et "cURL lite", cette dernière surchargeant les fonctions cURL.
google_app_engine.enable_functions
: Fonctions désactivées de manière réversible dans App Engine, mais qui peuvent être réactivées à l'aide de cette directive. Les noms de fonctions doivent être énumérés dans une chaîne délimitée par des virgules comme ci-après :
google_app_engine.enable_functions = "phpversion, phpinfo"
google_app_engine.allow_include_gs_buckets
: Autorise votre application à utiliser les instructions include
ou require
avec des fichiers stockés dans Google Cloud Storage.
Remarque : Vous pouvez utiliser #default#
pour le bucket par défaut. Cette valeur sera automatiquement remplacée lors de l'exécution par le nom de votre bucket par défaut actuel.
Par exemple, répertoriez le bucket par défaut, ainsi que les buckets bucket_1
et bucket_2
contenant les fichiers dans une chaîne délimitée par des virgules :
google_app_engine.allow_include_gs_buckets = "#default#, bucket_1, bucket_2"
Vous pouvez également spécifier un bucket avec un chemin d'accès aux fichiers inclus, par exemple :
google_app_engine.allow_include_gs_buckets = "bucket_1/path_x"
Lorsque la vérification des fichiers pouvant être inclus à partir de Google Cloud Storage est effectuée, le chemin fourni est traité comme un préfixe qui doit correspondre au début du nom de fichier pour pouvoir être inclus ou requis. Par exemple, l'exemple de chemin ci-dessus permet aux utilisateurs d'inclure des fichiers de gs://bucket_1/path_x/...
, car le préfixe correspond, mais pas de gs://bucket_1 or gs://bucket_1/path_y/
, car le préfixe ne correspond pas.
Si un fichier importé est déplacé vers un bucket d'inclusion autorisé, un avertissement est généré pour alerter l'utilisateur en cas d'attaque LFI potentielle. Si cela se produit, nous vous recommandons d'utiliser un chemin plus restrictif.
Remarque : Le chemin est traité comme un préfixe de fichier. Il peut donc également inclure un fichier spécifique, par exemple, 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
: Par défaut, les applications PHP ne sont pas autorisées à écrire sur le système de fichiers.
Définir cette directive sur "1" lève la restriction pour l'environnement de développement local.
Toutefois, le paramètre ne s'applique pas aux applications en cours d'exécution dans l'environnement de production, celles-ci étant toujours soumises aux restrictions de bac à sable.
≥ 99,99 %
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)."]]