PHP 5 ha raggiunto la fine del supporto e verrà
ritirato
il 31 gennaio 2026. Dopo il ritiro, non potrai eseguire il deployment di applicazioni PHP 5, anche se la tua organizzazione ha utilizzato in precedenza un criterio dell'organizzazione per riattivare i deployment di runtime legacy. Le tue applicazioni PHP
5 esistenti continueranno a essere eseguite e a ricevere traffico dopo la
data di ritiro. Ti consigliamo di
eseguire la migrazione all'ultima versione supportata di PHP.
Utilizzo dell'API Modules
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
L'API Modules fornisce funzioni che restituiscono informazioni sull'ambiente operativo corrente (modulo, versione e istanza).
L'API Modules dispone anche di funzioni che recuperano l'indirizzo di un modulo, una
versione o un'istanza. Ciò consente a un'applicazione di inviare richieste da un'istanza a un'altra, sia negli ambienti di sviluppo che di produzione.
Aggiungi la seguente istruzione use all'inizio del file:
Il seguente esempio di codice mostra come ottenere il nome del modulo e l'ID istanza per
una richiesta:
L'ID istanza di un modulo scalato automaticamente verrà restituito come valore univoco
codificato in base64, ad es. e4b565394caa
.
Puoi comunicare tra i moduli della stessa app recuperando il nome host del modulo di destinazione:
Puoi anche utilizzare il servizio Recupero URL.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-09-04 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThe Modules API provides information about the current operating environment, including module, version, and instance details.\u003c/p\u003e\n"],["\u003cp\u003eThis API allows applications to retrieve the address of a module, version, or instance, facilitating inter-instance communication within the development and production environments.\u003c/p\u003e\n"],["\u003cp\u003eTo use the Modules API, you must include the \u003ccode\u003euse google\\appengine\\api\\modules\\ModulesService;\u003c/code\u003e statement at the top of your file.\u003c/p\u003e\n"],["\u003cp\u003eThe API can get the current module name and instance ID, and an automatically scaled module's instance ID will be a unique base64 encoded value.\u003c/p\u003e\n"],["\u003cp\u003eCommunication between modules within the same application can be achieved by fetching the hostname of the target module using the \u003ccode\u003eModulesService::getHostname()\u003c/code\u003e function.\u003c/p\u003e\n"]]],[],null,["# Using the Modules API\n\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| php-gen2\n|\n| /services/access). If you are updating to the App Engine PHP 7/8 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/php-differences) to learn about your migration options for legacy bundled services.\n\nThe Modules API provides functions that return information about the current\noperating environment (module, version, and instance).\n\nThe Modules API also has functions that retrieve the address of a module, a\nversion, or an instance. This allows an application to send requests from one\ninstance to another, in both the development and production environments.\n\nAdd the following use statement to the top of your file: \n\n use google\\appengine\\api\\modules\\ModulesService;\n\nThe following code sample shows how to get the module name and instance id for\na request: \n\n $module = ModulesService::getCurrentModuleName();\n $instance = ModulesService::getCurrentInstanceId();\n\nThe instance ID of an automatic scaled module will be returned as a unique\nbase64 encoded value, e.g. `e4b565394caa`.\n\nYou can communicate between modules in the same app by fetching the hostname of\nthe target module: \n\n use google\\appengine\\api\\modules\\ModulesService;\n\n $url = 'http://' . ModulesService::getHostname('my-backend') . '/';\n $result = file_get_contents($url);\n\nYou can also use the [URL Fetch](/appengine/docs/legacy/standard/php/issue-requests) service."]]