When should I generate a mix umbrella vs a phoenix umbrella?
Asked Answered
D

1

9

I'm not sure when to use mix and when to use phoenix for creating umbrella applications.

I have read a lot of articles online but they are not clear of the reasoning for using mix over phoenix and vis versa.

mix gives:

- apps/
- config/

phoenix gives:

- build/dev/(consolidated/lib)
- apps/(app_name/app_name_web)
- config/(configs for different envs)
- deps/(stuffffff)

mix new [UMBRELLA NAME] --umbrella VS mix phx.new [UMBRELLA NAME] --umbrella

If I want to generate an umbrella that has an application that will serve html/json, how should I look at these commands?

Dutiable answered 31/5, 2019 at 15:4 Comment(4)
If in doubt, you probably do not need an umbrella at all.Alissaalistair
Keep in mind, a lot of the time you may not actually need an umbrella application. However, if you are trying to choose whether you want a regular Elixir umbrella or a phoenix umbrella. The answer comes down to whether or not you are building a Phoenix application. If not, then stick with an Elixir umbrella. If yes, then make the Phoenix umbrella. You will not be stuck with your decision. If you started with an Elixir umbrella and decided later you want a phoenix project in your umbrella, you can still generate one with the mix phx.new command.Hogweed
I'm reading Phoenix In Action 1.4, and it uses $ mix new --umbrella auction_umbrella. Then inside the apps/ directory, the book does: $ mix new auction --sup to create the "application". Then after getting the application to run on its own, it creates the web interface to the application with: .../apps$ mix phx.new.web auction_web --no-ecto. I guess José Valim is saying that if you use $ mix phx.new --umbrella auction_web then those two apps will already be created for you.Malacostracan
My experience says otherwise: it's much harder to move to an umbrella architecture and project structure later on, and you don't really lose anything by starting with an umbrella structure to begin with.Pentahedron
E
15

At the end of the day, they are both the same thing. The difference is that Phoenix already generates an umbrella with two applications, one for your domain and another for the web, and if you ran mix new you would have to assemble everything by hand. So if you are building a web application, use Phoenix, because it will give you a head start on setting everything up.

Einsteinium answered 31/5, 2019 at 17:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.