Phoenix directory structure when using `mix phx.new`?

I can’t seem to find any explanation of the directory structure created by:

$ mix phx.new hello

I’ve looked through both Programming Phoenix > 1.4 and Phoenix in Action (v6), as well as the phoenixframework website. At the present time, I’m interested in knowing what the priv dir is for, but I’d also like at least a cursory explanation of what each of the other directories is for.

For Phoenix 1.3 and 1.4 you want mix phx.new hello. mix phoenix.new gives you the old structure.

The priv directory is a folder that holds static assets, migrations, and other files that aren’t compiled as part of running your program but need to be shipped with it anyway.

1 Like

Thanks for the response.

Okay. That was a typo on my part (I’ve never used phoenix.new).

The priv directory is a folder that holds static assets, migrations, and other files that aren’t compiled as part of running your program but need to be shipped with it anyway.

How did you learn that? The directories must be explained somewhere in the docs, right?

1 Like

Directories are explained in the context of functionality - example:

Endpoint Contents

Static files are served from priv/static before any part of our request makes it to a router.

Probably a side effect from having most of the documentation inline with the source code.

2 Likes

Yupp, this is an erlangism and documented at least in the OTP anatomy. I’m not sure though if it’s documented within elixir as well.

1 Like

Okay. Thanks for the example!

Arghh. I read about the erlang Application directory structure in the erlang docs last week, and I misremembered it being in Programming Phoenix, and I was flustered that I couldn’t find it. :frowning:

Thanks.

It explains it in Programming Phoenix > 1.4

priv dir is where you do seed and migration which is the last two chapters of part i of the Programming Phoenix > 1.4 book. You have to seed categories.

lib library is where most of your serverside code are at. there is lib/hello and lib/hello_web. hello is where you model (which is broken down to context and schema) are at. controller, views and templates are in hello_web.

dep is where your package lives if you use any or just the default phoenix ones.

config is where you config stuff either phoenix or packages you’ve install.

asset is your web asset lives.

tests is where your test live which you do in the book too.

Page number?

Are you talking about priv dir?

Or overall general?

Overall in general is on pg 26 p6 version of the book under the section Phoenix File Structure.

For priv and adding categories it’s chapter 7 page 121.

Chapter 8 goes over test which is tests dir. pg 145.

1 Like

Thanks!

1 Like

Check out the Adding Pages guide, most of the directories are (shortly) explained there.

1 Like