Advice for creating a Phoenix-based package

Hi I’m trying to make a package for phoenix projects. It would contain a controller, view and templates. It would also use Ecto. Maybe it’s own router it that’s what’s needed. Maybe an overridable view

I’m having trouble figuring out how to do it without knowing the name of the app it will go into (Web). This matters for things like using the helpers, etc

Anyone have any advice on how to make a package for phoenix apps like this?

I’ve made plenty of plug packages, but I think this one would need to be dependent on Phoenix. Also I’m just curious if anyone has done something like this before.

It’s an admin thing for the curious.

2 Likes

I would annotate the conn via an explicit option upstream in the plug stack, ie:

forward "/admin", BryanAdmin.Router, otp_app: :my_app, repo: MyRepo, 
6 Likes

Thanks @chrismccord! I think that might work well. I’ve gotten pretty far with the config, but putting in the plug opts I think will work better.