---
title: WordPress Constants
description: Reference for the WordPress constants Autoscale sets for every environment, how to define your own in config/config.php, and how to store sensitive values as secrets.
url: https://developers.wpengine.com/docs/managed-hosting-platform/autoscale/constants/
image: https://developers.wpengine.com/og/docs/managed-hosting-platform/autoscale/constants.png
---

# WordPress Constants

Autoscale generates `wp-config.php` per environment. It is not part of your repository and cannot be edited. Set your own constants in `config/config.php` in your repository, or, for sensitive values, as secrets in the User Portal.

## Load order

wp-config.php

```php
require_once '/config/platform.php';


if ( file_exists( __DIR__ . '/wp-content/config/config.php' ) ) {
  require_once __DIR__ . '/wp-content/config/config.php';
}
```

`platform.php` holds the platform-managed constants, followed by your secrets. `config/config.php` loads last.

The first `define()` of a constant wins, so precedence is platform constants, then secrets, then `config/config.php`. Redefining an earlier name has no effect and emits a PHP warning.

## Platform-managed constants

These are set for every environment and cannot be overridden.

| Constant            | Value                                        | Notes                                                                                       |
| ------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `PWP_NAME`          | Your environment name, as in the User Portal | Fixed when the environment is created. Unique across WP Engine.                             |
| `WPE_PLATFORM_NAME` | `autoscale`                                  | Always this value on Autoscale. Use it to detect that your code is running on the platform. |

## Defining your own constants

Add `config/config.php` to the root of your repository. It is built into your image, so changes require a deployment.

Guard every `define()` call:

config/config.php

```php
<?php


if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
  define( 'WP_MEMORY_LIMIT', '512M' );
}


if ( ! defined( 'MY_APP_API_BASE' ) ) {
  define(
    'MY_APP_API_BASE',
    'my-site-prod' === PWP_NAME ? 'https://api.example.com' : 'https://sandbox.api.example.com'
  );
}
```

Because `config/config.php` is the same file in every environment, branch on `PWP_NAME` when a value needs to differ between them. For values that should not be in your repository at all, use [secrets](https://developers.wpengine.com/docs/managed-hosting-platform/autoscale/constants/#secrets), which are set per environment.

For the constants WordPress itself recognizes, see the [wp-config.php reference](https://developer.wordpress.org/advanced-administration/wordpress/wp-config/).

> **Do not put secrets in config.php**
>
> `config/config.php` is committed to your repository and built into your image. Use [secrets](https://developers.wpengine.com/docs/managed-hosting-platform/autoscale/constants/#secrets) for credentials, API keys, and license keys.

## Secrets

A secret is a constant whose value is stored by WP Engine rather than in your repository. Values are set per environment and never appear in Git or in your built image.

Manage them in the User Portal under **Environment Secrets**:

```text
https://my.wpengine.com/installs/<environment-name>/environment_secrets
```

![Environment Secrets in the User Portal](https://developers.wpengine.com/_astro/portal-secrets.BvmKZdS9_YK4V6.webp)

The name you enter becomes the constant. A secret named `EXAMPLE_SECRET` is defined for you at startup:

platform.php

```php
define( 'EXAMPLE_SECRET', 'the value you entered' );
```

| Field | Rule                                                                                             |
| ----- | ------------------------------------------------------------------------------------------------ |
| Name  | Letters, numbers, and underscores only, starting with a letter or an underscore.                 |
| Name  | Unique within the environment, ignoring case.                                                    |
| Value | Required, and cannot be empty.                                                                   |
| Value | A single line of printable text. Single quotes, double quotes, and backslashes are not accepted. |

> **A new value takes a few minutes to apply**
>
> Secrets are added and updated on their own, without a code change and without running your deployment pipeline. The value is read when a pod starts, so the platform restarts your pods to pick up a new one. Allow a few minutes before the value is available to your code.

## Reading a constant in your code

Constants behave the same whatever defined them. A platform constant, one from `config/config.php`, and a secret are all read by name from any theme, plugin, or must-use plugin:

```php
$response = wp_remote_get(
  'https://api.example.com/v1/orders',
  array(
    'headers' => array( 'Authorization' => 'Bearer ' . EXAMPLE_SECRET ),
  )
);
```

All three sources load before WordPress loads plugins and themes, so a constant is available everywhere your code runs. Use `defined()` first for anything optional, such as a secret that exists in production but not in every environment:

```php
$api_key = defined( 'EXAMPLE_SECRET' ) ? EXAMPLE_SECRET : '';
```

> #### Related Content
>
> - [WordPress Core Version](https://developers.wpengine.com/docs/managed-hosting-platform/autoscale/wordpress-version)
> - [WordPress on Autoscale](https://developers.wpengine.com/docs/managed-hosting-platform/autoscale/wordpress)
> - [Autoscale Architecture](https://developers.wpengine.com/docs/managed-hosting-platform/autoscale/architecture)

## Was this helpful?

Thanks for the feedback!

```json
{"@context":"https://schema.org","@graph":[{"@type":"WebSite","@id":"https://developers.wpengine.com/#website","name":"WP Engine Product Documentation","url":"https://developers.wpengine.com/","description":"Resources for developing, deploying, and scaling on WP Engine.","inLanguage":"en-US","keywords":["API documentation","product documentation","headless WordPress","managed WordPress hosting"],"publisher":{"@id":"https://wpengine.com/#organization"}}]}
```
