Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I never use `resources` though have no beef with `pipeline` or `scope`, though I haven't thought too much about it. It is a little weird getting used to which modules are getting auto-qualified and which aren't, but I'm long passed that. And that is actually what is "fixing" the cyclical dependency issue.

What's wrong with the `use MyApp.Web, :x`? You can easily get rid of it as it's just generated boilerplate. It's a nice little pattern to allow all the different things to share the view helpers. If you'd like to be extra explicit, though, just delete the file and include everything manually.

I'm indifferent on views because I never really used them, haha.



I personally would prefer something like:

    defmodule MyApp.Web.Router do
      use MyApp.Router
    end
over

    defmodule MyApp.Web.Router do
      use MyApp, :router
    end
but that’s a preference.


You can do that if you want. Just remove `def router` from `MyAppWeb` move its contents over to a custom module:

    defmodule MyAppWeb.Router do
      defmacro __using__(_) do
        quote do
          use Phoenix.Router, helpers: false

          import Plug.Conn
          import Phoenix.Controller
          import Phoenix.LiveView.Router
        end
      end
    end
But why the dislike for passing a second argument to `use`? It keeps everything together pretty nicely.


Mostly because we’re using an umbrella at the place of work, and we absolutely don’t want those boundaries crossed.


Oh! Well I don't know your setup but you could always add a top level `PhoenixHelpers` namespace (or a better name) that holds these generic types of things that can be shared between apps. Though again I really don't know your set up. Like maybe you have an app whose router doesn't need `Phoenix.Controller` so then this wouldn't make sense.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: