Phoenix

https://hexdocs.pm/phoenix/installation.html

Phoenix vs. Mix?

Phoenix: isA full-featured web development framework specifically for building web apps (with advanced real-time features like LiveView).

  • Mix is just some build and project management ool

The basic idea of Plug is to unify the concept of a “connection” that we operate on.

Resources

The core Phoenix components like endpoints, routers, and controllers are all just plugs internally.

  • It’s an abstraction for connections
def introspect(conn, _opts) do
  IO.puts """
  Verb: #{inspect(conn.method)}
  Host: #{inspect(conn.host)}
  Headers: #{inspect(conn.req_headers)}
  """
  • The _opts is because you are not using that variable, so it’s normal to have an underscore for it

Pipelines

  • There’s :browser, and there’s :api

There’s the

resources "/users", UserController
  • This will kind of create a default

Routing

get "/", PageController, :home

This means that when a get request is received, it will be routed to the PageController, calling the the home/2 function.