I am playing with different ways of structuring Phoenix applications and have come upon a frustrating scenario in which I can’t seem to get the right incantation of
mix phx.new. Here’s what I’m trying to accomplish.
If you were to run
mix phx.new cocktail --umbrella, it would create a structure similar to this (truncated):
cocktail/ apps/ cocktail/ lib/ cocktail.ex cocktail/ mix.exs cocktail_web/ lib/ cocktail_web.ex cocktail_web/ mix.exs
cocktail, the app name is
cocktail and for
cocktail_web, the app name is
cocktail_web — as you’d expect.
cocktail_web's module name is
CocktailWeb and the generated controller name is
CocktailWeb.PageController which is perfect.
Now the issue I’m having is that I have created a straight Elixir app named
cocktail that contains my business logic. I’d like to create a Phoenix application named
cocktail_web that is a presentation layer for that data, but I’m having the hardest time getting the right mix of
--module to get it to generate files similar to how
mix phx.new cocktail --umbrella would generate the web side.
I would like the app to be named
cocktail_web but the generator always creates a file structure like this
cocktail_web/ lib/ cocktail_web/ cocktail_web.ex cocktail_web_web/ controllers, etc. cocktail_web_web.ex
How can I keep it from putting all the web-centric stuff in
cocktail_web_web? Can I use the generator to create a structure similar to
mix phx.new cocktail --umbrella?
Hopefully all that made sense.