<p>Yes it's absolutely possible, and available out of the box with craft.</p>

<p>In your <code>public/index.php</code> file you specify the different environments based on your server name.</p>

<p>With the environment set, inside your <code>craft/config/db.php</code> and <code>craft/config/general.php</code> files, you can create different configurations for each environment.</p>

<p>This article in the craft documentation goes over how to configure it. Let me know if you have any trouble, it's really just modifying those three files.</p>

<p><a href="http://buildwithcraft.com/docs/multi-environment-configs" rel="nofollow">http://buildwithcraft.com/docs/multi-environment-configs</a></p>

CC BY-SA 3.0
2015-10-06T15:44:57.063Z
To add to this nice answer: you can set up a custom setting (e.g. "myCustomSetting") just like you do default / core settings and then access it from the template with `craft.config.myCustomSetting`.
carlcs
CC BY-SA 3.0
2015-10-06T15:47:53.557Z
Oh, and there's no need to have them under "environmentVariables" (just noticed that the OP linked to this).
carlcs
CC BY-SA 3.0
2015-10-06T20:39:31.853Z
Oh wow. Thank you both Bryant and @carlcs for taking the time to answer such simple question. Kind of embarrassed with how simple the solution was. I think I need to unplug. Thanks again!
Kevin
CC BY-SA 3.0
2015-10-06T15:23:01.560Z
2015-10-06T15:23:01.560Z
Bryant
<p>Is it possible to use custom environmental settings with Craft?</p>

<p>I have separate web services that I use in production and development environments. I would like to programmatically point to the appropriate service based on my environment. If I am in development, I should always point to the dev service...production...to the production service.</p>

<p>The <a href="http://buildwithcraft.com/docs/config-settings#environmentVariables" rel="nofollow">documentation</a> leads me to believe that I can only use the settings that Craft provides.</p>

<p>How can I use custom environmental settings within Craft?</p>

<config><multi-environment><environmentvariables>
Custom Environmental Settings
# Custom Environmental Settings

(Asked by: username_0 on 2015-10-06)

Is it possible to use custom environmental settings with Craft?

I have separate web services that I use in production and development environments. I would like to programmatically point to the appropriate service based on my environment. If I am in development, I should always point to the dev service...production...to the production service.

The [documentation](http://buildwithcraft.com/docs/config-settings#environmentVariables) leads me to believe that I can only use the settings that Craft provides.

How can I use custom environmental settings within Craft?

**Tags:** config, multi-environment, environmentvariables


---

## 1 answers

### Answer by username_1 on 2015-10-06. Score: 3 | Accepted answer

Yes it's absolutely possible, and available out of the box with craft.

In your `public/index.php` file you specify the different environments based on your server name.

With the environment set, inside your `craft/config/db.php` and `craft/config/general.php` files, you can create different configurations for each environment.

This article in the craft documentation goes over how to configure it. Let me know if you have any trouble, it's really just modifying those three files.

<http://buildwithcraft.com/docs/multi-environment-configs>

> **Comments:**
> **username_2**: To add to this nice answer: you can set up a custom setting (e.g. "myCustomSetting") just like you do default / core settings and then access it from the template with `craft.config.myCustomSetting`.  
> **username_2**: Oh, and there's no need to have them under "environmentVariables" (just noticed that the OP linked to this).  
> **username_0**: Oh wow. Thank you both username_1 and @username_2 for taking the time to answer such simple question. Kind of embarrassed with how simple the solution was. I think I need to unplug. Thanks again!  

---

