Dano Manion

Phoenix Notes

Phoenix is about fast, concurrent, beautiful, interactive, and reliable applications. (Start with the end in mind)

Performance: The more cores the better the performance got.

Tools

Start an interactive console

iex -S mix 

Controler

connection
|> endpoint
|> router
|> browser_pipeline
|> UserController
  • A request enters through the endpoint (lib/rumbl/endpoint.ex) and then goes into the router (web/router.ex) The router matches the URL pattern and dispatches the connection through the browser pipeline, which then calls UserController. Let’s break that last part down a little further, assuming that the request invokes the index action:

    connection |> UserController.index |> UserView.render(“index.html”)

Routes

:show, :index, :new, :create, :edit, :update, and :delete actions are all frequently used in Phoenix

Views

  • Views are modules responsible for rendering.
  • A view is a module containing rendering functions that convert data into a format the end user will consume, like HTML or JSON.

  • This code snippet is the one responsible for setting up our view modules, importing all required functionality.

      use Rumbl.Web, :view
    

Templates

  • Templates: are web pages or fragments that allow both static markup and native code to build response pages, compiled into a function.