Chapter 15. Using Phoenix

While it’s great to use Elixir from the command line, sometimes you’ll want to expose your work to the Web as well. The Phoenix framework offers an Elixir-based toolkit, somewhat like Ruby on Rails, for building web applications. Phoenix is designed for robustness and scalability, building on macros, OTP, and Erlang’s Cowboy server. It wraps those powerful features, though, so you can get started building simple things without mastering those details.

Skeleton installation

Once you have Elixir itself installed, installing just Phoenix isn’t difficult. Installing everything that Phoenix might want, including PostgreSQL and Node.js is more than this introduction can cover, but you can do (at least sort of) useful things with only Phoenix.

To get started, install Phoenix from mix:

mix archive.install
Are you sure you want to install archive ""? [Yn] y
* creating .mix/archives/phoenix_new

Once you’ve installed Phoenix, you can have it build a minimalist application. The --no-brunch directive turns off Phoenix’s support for managing assets, which requires you to install Node. --no-ecto turns off the object relational mapping (ORM) that expects you to have installed PostgreSQL.

 $ mix fall --no-brunch --no-ecto * creating web/config/config.exs * creating web/config/dev.exs ... * creating web/web/views/layout_view.ex ...

Get Introducing Elixir now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.