Rationale for Page* nomenclature?

I’d like to understand the rationale for the Page* nomenclature. I mean, they’re all pages, right?

More to the point, is there some reason I shouldn’t use (say) Index*, instead? In particular, is there some special magic attached to names such as PageController, PageView, etc. Inquiring gnomes need to mine…


I believe that the default controller Phoenix makes is called PageController (and the linked view PageVew) only as a simple naming convenience, which makes sense (to me at least) since most web apps have some (semi-)static page(s), like the page(s) a visitor visits before logging in.

As far as I know, there is nothing magical about them or their name. It is just a sensible default :slight_smile:


Yeah I don’t have a single thing named ‘page’ anywhere… ^.^;

For note, the pattern follows <Name>Controller and <Name>View and so forth, the default Page name is just a template thing.

As others have said, the only place we use “page” is the default controller, PageController. It’s named “page”, because it serves up the only page of the application – the index page. You could also imagine other nav related pages going here, “about”, “contact”, etc.

1 Like

So the PageController handles pages that are related to the app as a whole?

Personally I use PageController to render pages that don’t require any (or very little) special business code to render, i.e. mostly static pages, and that are not closely related to any feature of the website. Like index page, legal, help pages, contact page etc.

Personally I delete PageController altogether and beside that have controllers namespaced under Controller namespace like MyApiWeb.Controllers.Contact etc. PageController is just a name, you can do with it anything you want. There is totally 100% nothing special to the name PageController. It’s named PageController by default, because it’s serving a simple web page by default (and by default I mean, until you you write your own logic and controllers) :slight_smile: It could be named SiteController, or MainContoller, or ChangeMyNameToWhateverFitsYouContoller.

PS. Actually there are no proper namespaces in Elixir but that is something totally out of scope, and by namespaced I mean having the same prefix __APP_NAME__.Controllers.*

1 Like