Skip to content

Elixir Mix Build Tool — Projects, Tasks, Dependencies, and Configuration

DodaTech Updated 2026-06-29 1 min read

In this tutorial, you will learn about Elixir Mix Build Tool. We cover key concepts, practical examples, and best practices to help you master this topic.

Mix is Elixir's build tool — it handles project creation, compilation, testing, dependency management, and custom tasks.

Creating Projects

mix new my_app          # Standard project
mix new my_app --sup    # With supervision tree
mix phx.new my_app      # Phoenix project

Common Tasks

mix compile             # Compile project
mix test                # Run tests
mix run                 # Run project
mix format              # Format code
mix deps.get            # Fetch dependencies
mix deps.update --all   # Update all deps
mix dialyzer            # Static analysis

Custom Mix Tasks

# lib/mix/tasks/hello.ex
defmodule Mix.Tasks.Hello do
  use Mix.Task

  @shortdoc "Prints a greeting"
  def run(_args) do
    Mix.shell().info("Hello from Mix!")
  end
end

# Run: mix hello

Configuration

# config/config.exs
use Mix.Config

config :my_app, :server,
  port: String.to_integer(System.get_env("PORT") || "4000")

import_config "#{Mix.env()}.exs"

# config/dev.exs, config/prod.exs, config/test.exs

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro