Install Elixir
$ brew install elixir
Install/Update Mix
$ mix local.hex
Install Phoenix
$ mix archive.install hex phx_new 1.4.0
Create new Phoenix API
$ mix phx.new my-app --no-webpack --no-html
Run Interactive Mode
$ iex -S mix # run recompile() for any change
$ MIX_ENV=test iex -S mix
Seed Data
$ mix run priv/repo/seeds.exs
Create Docs
$ mix docs
DocTests
IEx.pry
Recommended Shortcuts
Add the following code to defp aliases do
in mix.exs
.
# Aliases are shortcuts or tasks specific to the current project.
# For example, to create, migrate and run the seeds file at once:
#
# $ mix ecto.setup
#
# See the documentation for `Mix` for more info on aliases.
defp aliases do
[
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"],
"test": ["ecto.create --quiet", "ecto.migrate", "test"]
s: ["server"], # Start Web Server
d: ["phx.digest"], # Compile Static Asset
g: ["deps.get"], # Download Elixir/ Erlang Packages
db: ["ecto.migrate"], # Database Migration
r: ["phx.routes"], # Check Routing
m: ["phx.gen.model"], # Generate Model
]
end