The Modules API provides functions that return information about the current operating environment (module, version, and instance).
The Modules API also has functions that retrieve the address of a module, a version, or an instance. This allows an application to send requests from one instance to another, in both the development and production environments.
Add the following use statement to the top of your file:
The following code sample shows how to get the module name and instance id for a request:
$module = ModulesService::getCurrentModuleName(); $instance = ModulesService::getCurrentInstanceId();
The instance ID of an automatic scaled module will be returned as a unique
base64 encoded value, e.g.
You can communicate between modules in the same app by fetching the hostname of the target module:
$url = 'http://' . ModulesService::getHostname('my-backend') . '/'; $result = file_get_contents($url);
You can also use the URL Fetch service.