Environment Variables

The php cartridges provide several additional environment variables to reference for ease of use:

Variable Name Description

OPENSHIFT_PHP_IP

The IP address the application listens on.

OPENSHIFT_PHP_PORT

The port the application receives requests from.

The php cartridges also provides several environment variables to change the default PHP configuration:

Variable name Description

APPLICATION_ENV

Application mode, default setting is production. When set to development, the Xdebug extension is enabled, more verbose error_reporting and the APC.stat setting are set. See development mode for more details.

OPENSHIFT_PHP_APC_ENABLED

Whether APC op-code cache PECL is enabled, true by default. Set value to false to turn this extension off.

OPENSHIFT_PHP_APC_SHM_SIZE

The APC shared memory size. The default value is 64M on Small and Small.highcpu gears, 128M on Medium gears, and 256M on Large gears.

OPENSHIFT_PHP_XDEBUG_ENABLED

Whether Xdebug PECL is enabled, true by default. Set value to false to turn this extension off. This variable overrides behavior set by APPLICATION_ENV.

OPENSHIFT_PHP_<MODULE>_ENABLED

Whether <MODULE> PECL is enabled, true by default. Set value to false to turn the specified extension off. To list all enabled modules, run php -m command while ssh’d into the gear.

LOGSHIFTER_PHP_MAX_FILESIZE

A case-insensitive string representing the maximum log file size that triggers a roll event. The default value is 10M. If a zero size is specified regardless of the unit, log rolling is effectively disabled.

LOGSHIFTER_PHP_MAX_FILES

An integer representing the maximum number of log files to retain. The default is 10. See logging environment variables for more details.

You must restart the php cartridge to pick-up the updated values.
The above 'defaults' are the default setting, not the default value for the variables. If no user-created environment variable is set, the default setting will be used.

Reading Environment Variables

The following example demonstrates how to read environment variables within your application code:

$env_var = getenv('OPENSHIFT_ENV_VAR');

Developers can safely store API keys and other credentials in the system environment by using rhc env set, allowing for clean and portable application sources. Learn more about using environment variables.