Course contentsShow
← Software Engineering
Lesson 739 of 1,93323. Configuration ManagementFree lesson

Local Development Configuration

Using .env files and local overrides to configure applications in development without affecting version control.

Local Development Configuration

What you'll learn: How to use .env files and local overrides to manage configuration during development without polluting version control.

The Problem of Developer-Specific Settings

When developing locally, you often need different configuration values than production—like a local database URL, debug flags enabled, or a personal API key. If everyone commits their personal settings to version control, you get constant conflicts and accidental exposure of secrets.

Enter .env Files

A .env file is a simple text file that lives in your project root and contains key-value pairs:

DATABASE_URL=localhost:5432
DEBUG_MODE=true
API_KEY=my-dev-key-12345

The key insight: add .env to your .gitignore so each developer has their own local copy that never gets committed.

How It Works in Practice

Your application reads the .env file at startup and loads those values as environment variables. Most languages have libraries that handle this automatically (like dotenv in JavaScript or python-dotenv in Python).

You typically commit a .env.example file showing what configuration is needed, but with dummy values:

DATABASE_URL=your-database-here
DEBUG_MODE=false
API_KEY=get-from-team-lead

New developers copy this to .env and fill in their own values.

Local Overrides

This approach follows the precedence hierarchy you learned earlier: local .env files override default configuration files, but actual environment variables override everything. This gives developers maximum flexibility.

Key Takeaway: .env files let each developer maintain their own local configuration safely outside version control, while .env.example documents what configuration is required—balancing security, flexibility, and team coordination.