Phoenix Namespacing - is HelloWeb module in hello_web.ex?

mix hello creates

defmodule HelloWeb.HelloController do
  use HelloWeb, :controller

  def world(conn, _params) do
    render(conn, "world.html")

How is HelloWeb visible in this module? There are statement that includes it. Is it the HelloWeb module in hello_web.ex? Please explain.


What do you mean by visible? A module name (HelloWeb) is just an atom, so it’s visible everywhere it is written like any other literal value (ints, strings).

1 Like

Where is HelloWeb?

Probably in lib/hello_web.ex.

What’s this,

defmacro __using__(which) when is_atom(which) do
    apply(__MODULE__, which, [])

A macro definition, it effectively delegates to the function that is described through the passed in atom when called.