What is the difference between importing controllers and use controllers in phoenix

I have a quick questions what is the difference between

import Phoenix.Controller and use Example: controller

Typing import SomeModule will just bring all of its functions into your current scope so instead of typing SomeModule.foo() you can type foo().

The keyword use will execute the macros in the following module, and potentially add new syntax as well as injecting code into your module.

The Ecto DSL and the syntax in the router file in any Phoenix app are examples of this.

3 Likes