Note: Local config for Phoenix

May 14, 2025
elixir phoenix

Here’s a handy tip: create Phoenix configurations that live only on your machine, not in version control.

I use this for setting machine-specific domain names. It’s ideal for any development settings that shouldn’t live in your shared repository.

First, add this snippet at the bottom of config.exs:

if File.exists?("#{__DIR__}/#{config_env()}.local.exs") do
  import_config "#{config_env()}.local.exs"
end

Create a file named dev.local.exs and Phoenix will load it. Add this to your .gitignore to keep it local:

# Ignore local environment configs
*.local.exs

Your machine-specific settings won’t touch production or bother teammates. Common uses:

  • Local database credentials
  • Custom domain names (like dev.localhost)
  • Local service endpoints
  • Personal log levels

Everyone on your team can customize their environment without stepping on each other’s toes. Enjoy!

Downloading YouTube videos with yt-dlp