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 leads me to believe that I can only use the settings that Craft provides.

How can I use custom environmental settings within Craft?

1 Answer 1


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.


  • 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.
    – carlcs
    Oct 6, 2015 at 15:44
  • 2
    Oh, and there's no need to have them under "environmentVariables" (just noticed that the OP linked to this).
    – carlcs
    Oct 6, 2015 at 15:47
  • 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
    Oct 6, 2015 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.