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.

Most Liked Responses

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

Where Next?

Popular in Questions Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: <h1>Create Post</h1> <%= ...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
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

Other popular topics Top

albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
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
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
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
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement