Installing Elixir and Phoenix on a Mac
If you're a Rubyist and you're interested in building large-scale applications, Elixir is a very good alternative. It feels like Ruby but is structured like Erlang.
I'm currently researching Elixer for an upcoming project so here are my notes on how to install it for Mac.
Step 1 - Homebrew + PostgreSQL
Homebrew is amazing and if you're not familiar with it, read this first.
Here are instructions on how to install postgres for your database.
brew install postgresql
Step 2 - Elixir + Erlang
Elixir is the programming language and we use Homebrew to install it.
brew install elixir
Elixir is built on top of Erlang's virtual machine so we need Erlang.
brew install erlang
Step 3 - Phoenix Framework
Node is optional but it's used by Phoenix for compiling static assets.
brew install node
Hex is the package manager for Elixir. We'll need this for installations.
The latest version of Phoenix can be found within the archives. A
mix is Zip file which contains an application as well as its compiled BEAM files.
mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez
Step 4 - New App
Create a new Phoenix app.
mix phoenix.new [name_of_app]
Change directory into the Elixir app you've created.
Step 5 - Database
Ecto to connect to PostgreSQL so let's create an ecto user.
Create an ecto user in Postgres.
createuser ecto --pwprompt
Create a database for this project.
createdb -Oecto -Eutf8 name_of_db_development
Double check that you can login to postgres using ecto.
psql name_of_db_development --user ecto --password
# Configure your database ... adapter: Ecto.Adapters.Postgres, username: "ecto", password: "password", database: "chris_dev", hostname: "localhost", pool_size: 10 ...
Step 6 - Start App
Get the dependencies and compile the phoenix project before you go any further.
mix do deps.get, compile
Start your server.
Step 7 - Success
Visit http://localhost:4000/ to see your app in action.
Tips and Tricks
Create a barebone application
mix phoenix.new [name_of_app] --no-brunch --no-ecto
Access Interactive Elixir
Similar to Ruby's IRB, Elixir offers