Jonathan Bennett

Environments

Environments let you run your complete application with different sets of configurations. This is most frequently used to have a local development environment for building your application and a separate environment for customers to access, typically called production. This allows you to connect to a live Stripe account in production, but a test account while in development for example.

Why Bother?

Fair question. Building your application around a flexible configuration means you can easily change how your application runs without having a separate version of the code. What your configuration could change is endless but, the most common things are:

  1. Connections to alternate third party accounts – live vs test bank accounts
  2. Hosting infrastructure – one server vs multiple redundant servers
  3. Security – less secure but faster vs fully secured but slower

This makes it easy for the server to perform in slightly different ways with different settings, or the same way but pointing to a different account in the case of performing financial transactions

  Development Production
Bank ID test_123 real_abc
Server Ram 1gb 8gb
Encryption Work Factor 1 10

Example Environments

How do we use them?

Setting your environment variables is done by your operating system and web server. They can then be accessed through the ENV global variable, ENV["band_id"] for example in Ruby.

Splitting out your environments helps you keep you code clean, and testable. Try them on for size today!