O'Reilly logo

Introducing Elixir, 2nd Edition by J. David Eisenberg, Simon St. Laurent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 (the command line and output have been formatted to fit the page margins here, but you should enter the entire command on a single line):

$ mix archive.install 
https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez
Are you sure you want to install archive "https://github.com/phoenixframework/
  archives/raw/master/phoenix_new.ez"? [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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required