tomgosling88

tomgosling88

Phoenix 1.3 generated folder structure

Firstly want to thank you all for the brilliant work you have done, really exciting!

I would like to ask a question about design decisions regarding the generators in Phoenix 1.3.

Generating a Phoenix project from scratch nests the web folder is in the lib folder beside any contexts we create, an umbrella project gives two folders - the main folder presumably to house contexts and the web folder which is a dependency.

My question is why does a standard phoenix project and a phoenix project generated as part of an umbrella differ in structure?

If I generate a phoenix umbrella project from scratch, should I generate additional phoenix umbrella projects outside of the original umbrella then move the second_app and second_app_web folders into the original umbrella project or generate a standard phoenix app from within the original umbrella project with the nested web folder?

Maybe it’s just a matter of preference and has no intended design purpose or functional difference?

I know the question sounds convoluted and I may well have missed something extremely obvious, so apologies in advance should the question turn out to be an inane one.

First Post!

chrismccord

chrismccord

Creator of Phoenix

I’m not sure I follow the question entirely, but I think you are wondering why there is app/lib/web in a single app, and no app_web/lib/web in an umbrella app? In this case, the “web” namespace is redundant since the phoenix umbrella project is the web interface and nothing more. Does that answer your question?

Most Liked

wojtekmach

wojtekmach

Hex Core Team

to add on top of Michał’s answer, v1.3.0-rc.0 actually ships with two new tasks [1], so you can do the following:

mix new my_umbrella --umbrella
cd my_umbrella
mix phx.new.ecto myapp
mix phx.new.web myapp_web

and they’ll generate the child apps as if they were generated with mix phx.new --umbrella.

Please note these tasks are still private (no @shortdoc hence they don’t show up in mix help), I think they’re still under development so I wouldn’t count on them being present in the final release just yet.

[1] phoenix/installer/lib/mix/tasks at v1.3.0-rc.0 · phoenixframework/phoenix · GitHub

chrismccord

chrismccord

Creator of Phoenix

Single applications and umbrellas both have their own merits and pros/cons. We don’t generate an umbrella by default for Phoenix because it may be overkill and it introduces more decisions and overhead for folks to know. Umbrellas exist to house multiple isolated applications under a single code repo, that can be started and stopped as a whole or independently. This is a great for a number of reasons, but also introduces complexity depending on your needs. For example, for the mix phx.new --umbrella case you now have three places to configure things, three places to add new deps, three mix.exs files, etc. Our goal w/ the new structure for single applications where you are focusing on boundaries and isolation is the moment you need to extract the web interface or other parts of your single app to a separate umbrella app, it’s just a matter of cd apps/ && mix new whatever then moving the code around. Little else should need refactored provided your boundaries are well established. Does that help?

michalmuskala

michalmuskala

Also, if you want a regular phoenix structure in an umbrella you can do:

mix new my_umbrella --umbrella
cd my_umbrella/apps
mix phx.new web_app

Last Post!

tomgosling88

tomgosling88

Brilliant! I think I must have missed the phx.new.ecto task and it threw me why I couldn’t generate additional apps to match the structure of the inner app created by mix phx.new --umbrella.

Where Next?

Popular in Questions Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42576 114
New

We're in Beta

About us Mission Statement