El archivo php.ini
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Puedes incluir un archivo php.ini a tu aplicación de App Engine. Este archivo te permite personalizar el comportamiento de las directivas de intérprete de PHP.
Acerca de php.ini
El archivo php.ini
debe almacenarse en el directorio base de una aplicación (el mismo directorio que el archivo app.yaml
). Se carga cuando se inicializa el intérprete de PHP, antes de ejecutar el código de tu aplicación.
El archivo tiene la misma sintaxis que otros archivos .ini. Un ejemplo simple puede verse así:
; This is a simple php.ini file on App Engine
;
; This is a directive set to "On"
widget_compression = "On"
Una lista de las directivas principales se publica en php.net junto con sus valores de modo modificables. Las directivas php.ini
controladas por extensiones se documentan en las respectivas páginas de las mismas extensiones.
Puedes anular cualquier directiva de PHP que contenga uno de los siguientes valores de modo modificables:
PHP_INI_SYSTEM
PHP_INI_ALL
PHP_INI_PERDIR
Ten en cuenta que algunas funciones se inhabilitaron en la implementación de PHP en App Engine. Las directivas que se orientan a estas funciones no tendrán ningún efecto.
Se puede habilitar un conjunto de extensiones de carga dinámica con la directiva extension
.
Directivas de PHP para App Engine
Las siguientes directivas son específicas para el entorno de App Engine. Pueden estar incluidas en el archivo php.ini.
google_app_engine.enable_curl_lite
: Habilita “cURL lite”, una versión de cURL integrada, específica de App Engine, cuando se establece en “1”.
“cURL lite” se puede usar tal como usarías las funciones cURL, pero llama a la recuperación de URL de forma interna en lugar de sockets, por lo tanto, las funciones sin recuperación de URL equivalente arrojarán un CurlLiteMethodNotSupportedException
.
Nota: Una aplicación no puede habilitar la extensión “curl.so” y “cURL lite” al mismo tiempo, dado que la última sobrecarga las funciones cURL.
google_app_engine.enable_functions
: Funciones que se inhabilitaron por software en App Engine, pero que se pueden volver a habilitar con esta directiva. Genera una lista con los nombres de las funciones en una string delimitada por comas:
google_app_engine.enable_functions = "phpversion, phpinfo"
google_app_engine.allow_include_gs_buckets
: Permite que tu aplicación use las instrucciones include
o require
con archivos almacenados en Google Cloud Storage.
Nota: Puedes usar #default#
para el depósito predeterminado; este valor se reemplaza de forma automática en el entorno de ejecución con tu nombre de depósito predeterminado actual.
Por ejemplo, genera una lista de depósitos predeterminados, junto con los depósitos bucket_1
y bucket_2
que contengan los archivos en una string delimitada por comas:
google_app_engine.allow_include_gs_buckets = "#default#, bucket_1, bucket_2"
También puedes especificar un bucket y una ruta para los archivos que pueden estar incluidos, por ejemplo:
google_app_engine.allow_include_gs_buckets = "bucket_1/path_x"
Cuando se realiza la verificación de los archivos que se pueden incluir de Google Cloud Storage, se trata a la ruta suministrada como un prefijo que debe coincidir con el comienzo del nombre del archivo para que se lo incluya o requiera. Por ejemplo, con la ruta del ejemplo anterior, la ruta proporcionada debería permitir a los usuarios incluir los archivos de gs://bucket_1/path_x/...
ya que el prefijo coincide, pero no de gs://bucket_1 or gs://bucket_1/path_y/
, porque no coincide.
Si se transfirió un archivo subido a un depósito de inclusión permitido, se genera una advertencia para alertar al usuario de un posible ataque LFI. Si esto sucede, debes considerar usar una ruta de acceso más restringida.
Nota: Se trata a la ruta como un prefijo de archivo, de modo que pueda incluir también un archivo específico, por ejemplo, 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
: De forma predeterminada, no se permite a las aplicaciones de PHP escribir en el sistema de archivos.
Configurar esta directiva en “1” levantará la restricción del entorno de programación local.
Sin embargo, la configuración no afecta a las aplicaciones que se están ejecutando en producción, que siempre están sujetas a las restricciones en la zona de pruebas.
00:08:03,995 --> 00:08:06,690
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-09-04 (UTC)
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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)."]]