Manage environment variables for a VIP Local Development Environment
Managing environment values with the VIP-CLI vip config envvar
command is for VIP Platform environments only, and cannot be used on a VIP Local Development Environment. Instead, environment variables on a VIP Local Development Environment by managed manually by adding them as a defined constant instead.
Limitations
This method will only work for the VIP Local Development Environment as expected if:
- The
--app-code
option is set to a path for a git clone of an application’s wpcomvip GitHub repository on the local machine. - The constant for the added environment variable includes the prefix:
VIP_ENV_VAR_
.
Define an environment variable
Though definitions for constants can be added to any file loaded by WordPress, it is strongly recommended to create a file in the client-mu-plugins
directory that is dedicated to defining them for the local environment.
Note
If a local environment is created based on a VIP Platform environment, the names (but not the values) of the environment variables that exist on the VIP Platform environment are automatically defined in the local wp-config.php
. If any environment variables that are manually added to the local application codebase have the same name as the automatically added environment variables, a PHP warning will occur.
After creating the file, add it to .gitignore
(e.g. client-mu-plugins/*.local.php
) to avoid committing sensitive values to source control.
In this example, a file named client-mu-plugins/vip-env-vars.local.php
has been created and a definition for the environment variable MY_CUSTOM_VAR
is added:
<?php
/**
* Local environment variables
*/
define( 'VIP_ENV_VAR_MY_CUSTOM_VAR', 'my custom value' );
Once defined, the same methods for accessing environment variables in a VIP Platform environment can be used on the local environment:
$my_value = vip_get_env_var( 'MY_CUSTOM_VAR', $default_value );
Last updated: June 03, 2025