PHP Constants

This document is for a version of Craft CMS that is no longer supported. Please refer to the latest version →

There are a few optional PHP constants that you can define which affect Craft at a lower level than the config settings.

If you wish to define any of these constants for your site, you should put them in the index.php file in your site’s web root, after setting $craftPath:

// Path to your craft/ folder
$craftPath = '../../craft';

// This is for the Dutch site
define('CRAFT_SITE_URL', 'http://my-project.tld/nl/');
define('CRAFT_LOCALE',   'nl');

# General Constants

# CRAFT_ENVIRONMENT

Defines the name of the current environment, which defaults to the server’s hostname. (See multi-environment-configs for more info.)

define('CRAFT_ENVIRONMENT', 'dev');

# CRAFT_LOCALE

Sets the locale for the current request. Without setting this, your site’s primary locale will always be used.

define('CRAFT_LOCALE', 'nl');

# CRAFT_SITE_URL

Overrides the Site URL setting in Settings → General. That can be useful in combination with CRAFT_LOCALE for creating a locale-specific version of your site.

define('CRAFT_SITE_URL', "http://my-project.tld/nl/");

You’re free to use environment-specific variables in the value as well:

define('CRAFT_SITE_URL', "http://{host}/nl");

# Path Constants

# CRAFT_BASE_PATH

Craft uses this as the starting point for finding all of the folders traditionally located in craft/, with the notable exception of craft/app/, whose path gets defined with the help of your $craftPath variable in index.php.

// Path to your craft/ folder (where the app/ folder lives)
$craftPath = '../../craft';

// Path to where the rest of the craft/* folders live
define('CRAFT_BASE_PATH', '../craft_sitefiles/');

# CRAFT_CONFIG_PATH

Defines the path to your craft/config/ folder.

define('CRAFT_CONFIG_PATH', '../craft_sitefiles/config/');

# CRAFT_PLUGINS_PATH

Defines the path to your craft/plugins/ folder.

define('CRAFT_PLUGINS_PATH', '../craft_sitefiles/plugins/');

# CRAFT_STORAGE_PATH

Defines the path to your craft/storage/ folder.

define('CRAFT_STORAGE_PATH', '../craft_sitefiles/storage/');

# CRAFT_TEMPLATES_PATH

Defines the path to your craft/templates/ folder.

define('CRAFT_TEMPLATES_PATH', '../craft_sitefiles/templates/');

# CRAFT_TRANSLATIONS_PATH

Defines the path to your craft/translations/ folder.

define('CRAFT_TRANSLATIONS_PATH', '../craft_sitefiles/translations/');