cevado
when using phoenix generators it creates MyAppWeb.ResourceController and put it inside /lib/my_app_web/controllers/resource_controller.ex file. I was thinking if it wouldn’t be better if it followed the elixir standards and have a MyAppWeb.Controllers.Resource in a /lib/my_app_web/controllers/resource.ex file.
I understand that this is done that way so phoenix can abstract the default view from the controller module name, but it could be an option passed to MyAppWeb when using it. Something like use MyAppWeb, controller: [default_view: ViewModule].
Trending in Discussions
Hey there,
It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
I’ve been using Emacs as my main code editor for more than a two years. It’s a custom build version although I’ve tried doom emacs and sp...
New
Hi there! :wave:
@frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Latest Phoenix Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
Well, people use
aliasa lot and having e.g.Usersis going to be confusing, especially having in mind that Phoenix encourages you to have context modules with the model name in plural. So what wouldUsersmean? The context or the controller?al2o3cr
Beyond the aliasing issue @dimitarvp mentions, the bigger concern IMO is the “tab problem”.
In short, having many files with similar / identical names can cause confusion when users have an editor that only displays the base name of the file as a label. In your example, is a tab labeled
resource.exthe controller or the corresponding schema?Rust had a similar (but bigger) situation a few years back; the “default” place to put code for a module
The thread of discussion is long and tangled, but you can start from the final RFC that changed the approach so that
foowas infoo/mod.rs- so if you had many crates open, ALL the tabs would be namedmod.rsfoo.rswould work.tfwright
Wouldn’t the easy solve there to use the
:asoption? Although as I type that I realize my approach in Elixir apps that have this problem is to just alias up to the namespace so I can reference X.Users and Y.Users in any module that needs to reference both.dimitarvp
Indeed but then why rename in the first place? You’d save writing something like 5-6 characters at best, at the cost of using unnecessary renaming in other form (namely the
:asoption).tfwright
Good point. It seems like the as option only really helps with the NS immediately above the mod isn’t enough to distinguish it but something higher up is. But I’ve never worked on a a system where that was true.
dimitarvp
My rule of thumb for Elixir projects is: if your namespaces have 4 levels then it’s probably time to break apart your app.
As all such rules there are exceptions, obviously, but us the humans can only keep so much complexity in our heads.
BTW I never liked the “controller” moniker anyway. It’s IMO a misnomer and it would be more accurate as “HTTP inbound sink” (or something more brief than that; my English vocabulary isn’t great). The hell does it “control”?
If it were up to me I’d like have files like these:
lib/myapp_web/inbound/users_server.exlib/myapp/orders/cart.exlib/myapp_web/renderers/line_item_viewer.exOr some such.
cevado
@dimitarvp but why someone would reference a controller outside of a router or the actual controller test?
@al2o3cr isn’t that already a problem with the default elixir naming standard? why having two standards would solve that?
I think the main objective should be consistency. unfortunately, the web folder is an alien thing to the rest of the elixir code of a project.
dimitarvp
They very likely wouldn’t but aliasing things is a fact of life and IMO somebody is bound to get confused eventually. I wouldn’t risk it.
hauleth
This is exactly the approach I am using in my projects. Example controller. I really do not like the default approach where the “regular” naming scheme is broken. Thanks to that approach it router is IMHO much cleaner:
See Mama, no
Controllerrepeated over and over again.However recently I am thinking about grouping the controller, view, and templates within single “domain-oriented” directory.
cevado
i’ve been doing that too. i’d love to see it as a standard in the framework, and I say that because generators usually direct people to a standard solution. i feel so weird on the projects that I’ve worked that are the necessity of custom plugs and people created and named plugs according to the “phoenix standard”.
personally I only use generators for migrations and everything else I create by hand so it doesn’t impact me that much. one other thing that I usually change is the folder names too: