How to view phoenix routes in iex?

iex> Mix.Tasks.Phoenix.Routes.run ''                                              
page_path  GET   /           YourApp.PageController :index                                
user_path  GET   /users      YourApp.UserController :index                               
user_path  GET   /users/new  YourApp.UserController :new                                  
user_path  GET   /users/:id  YourApp.UserController :show                               
user_path  POST  /users      YourApp.UserController :create

Phoenix 1.3 update: mix phoenix.routes is deprecated. Use phx.routes instead. That is:

iex(7)> Mix.Tasks.Phx.Routes.run ''
 page_path  GET  /       HelloWeb.PageController :index
hello_path  GET  /hello  HelloWeb.HelloController :index

All the url/path helpers are compiled into functions in the module YourApp.Router.Helpers. You can import it and call with the same arguments as you would in your templates (you would probably pass conn as the first argument but since we don't have a conn in the iex session, you can pass YourApp.Endpoint instead):

iex(1)> import YourApp.Router.Helpers
nil
iex(2)> page_path(YourApp.Endpoint, :index)
"/"
iex(3)> task_path(YourApp.Endpoint, :show, 1)
"/tasks/1"

(I have a resources "/tasks", TaskController in this project.)


You can find the appropriate documentation for your requiement at the official docs here - http://www.phoenixframework.org/docs/routing#section-path-helpers

Assuming your app name is HelloPhoenix

iex> import HelloPhoenix.Router.Helpers
iex> alias HelloPhoenix.Endpoint
iex> user_path(Endpoint, :index)
"/users"

iex> user_path(Endpoint, :show, 17)
"/users/17"

iex> user_path(Endpoint, :new)
"/users/new"

iex> user_path(Endpoint, :create)
"/users"

YourApp.Web.Router.__routes__()