Sub-folders in "controllers" folder

I am studying Phoenix inside out series and I am at Chapter 4. May be what I’m asking is already explained in the later chapters of the book, but I can’t wait till that, I wan’t to know right now.

In Rails when the number of controllers grow, Rails developers often group controllers in sub-folders under controllers folder? then write the class as class Xyz::AbcController < Xyz::ApplicationController where xyz is the sub-folder in which we created the xyz_controller.rb
(app/controllers/xyz/abc_controller.rb)

How would we do the same in Phoenix?

Well, there aren’t classes or subclassing, so we may want to define exactly what you mean by “the same”.

In elixir module names aren’t tied to file names or folder names. You’re free to create as many subfolders as you like and then put modules named however you like in them. However it is conventional that if you have controllers/xyz/abc_controller.ex that you name it MyAppWeb.Xyz.AbcController.

So there’s definitely the ability to organize controllers in subfolders.

5 Likes

A quick and nice reply!

Thank You!