Post

I don't think it's just contexts' fault. I think it's also too much boilerplate that's needed to achieve basic stuff and LiveView not being part of the framework + its design with views and components being two different things. It's still the best stack on the planet if you asked me 🙃 (1/2)

George Millo@georgemillo.bsky.social

Did contexts kill Phoenix? New blog post: arrowsmithlabs.com/blog/did-con...

1 repost14 likes

Context's are a symptom of too much knowledge of naming is required up front to start a completely new project. Consider `mix phx.gen.html Accounts User users name:string age:integer`—Rails is `rails g resource User name:string age:integer`. Rails namespace is implicit, so I don't have to think.

Trade-off in Rails is bigger projects can become disorganized, but that's a luxury problem reserved for successful applications that accumulate users, tech debt, and revenue. Would be cool to see phx ship with implicit namespaces that can be organized into contexts when projects succeed.

I don't mind LiveView being outside Phoenix, but we urgently need multi-package search in hexdocs (mentioned few time by Jose that it's coming). I find contexts great, but that might be just scars from fat controllers, fat models, fat service objects, fat classes... fat... from Rails.

I also find them great because if I cannot come up with a good name, I do what docs suggest - plural version of schema, move on, revisit later when my domain is clearer. It's just a module.

The whole idea that Phoenix leaned into *Erlang* project structure conventions is just nuts. Why go from mimincing one of the most successful frameworks in history to now leaning into one that has struggled for adoption over three decades is mind boggling.

And I kill contexts dead in Alpha. I even blocked the generators. One thing I've heard: "if you don't like them, don't use them". The problem this ignores is that the files are still there. It causes confusion and bring productivity to a crawl if you don't know what to do with them

Great post, i can relate as a beginner with Phoenix inherent complexity. But i think it worth it to learn to organize your project right even if it is a mess at the beginning The alternative is to teach people a dummy phoenix for toy apps and then have to learn the right way in a real app.

This works sometimes, but most of the time you don’t know what you don’t know, so to speak. Get stuff done first, make it easy to refactor and tidy up later when you know more.

This is how it's always been on every project I work on regardless of the tech stack. I think putting too much up front is just a wasted effort and could cost you down the road, even if it means things are a little bit less "organized". A working feature-complete version is the only way to know.

Its just a tiring debate for the team lol. Before contexts: "We need structure! We need Patterns! How do we use phoenix??" After contexts: "This structure is too much!" Internal debate has been "we can't architect people's projects! People need to think! Modules and Functions is it!"

👏Modules 👏Functions Name them w/e you want! Could do it all in top level files if you wanted! one giant file! folder per module! w/e you want its just :"Elixir.Module.Name".function

Agreed. Even someone pushing effectively an alternative "core" for a Phoenix app, I'd still choose "vanilla" Phoenix and "regular" contexts over any other thing, and it's not even close.

I feel that recent shift from views to components does similar thing. I still cannot fully comprehend how I should handle JSON-only routes with that approach or how I should handle routes that return different format depending on the `Accept` header or URL extension.

kobrakai.de/kolumne/data... This lays out the changes for people coming from the old format. The "handle different data formats in the same module" portion simply doesn't exist in the default boilerplate anymore – there's now a format per module separation.

kobrakai.deData to ResponsesPhoenix 1.7's HEEx introduces new HTML rendering patterns, but under the hood, much remains unchanged—understanding these lower-level primitives clarifies how data becomes HTTP responses.

If anything I would prefer new projects to shift from `MyAppWeb.FooController` to IMHO "more natural" naming scheme of `MyAppWeb.Controllers.Foo` to match file path just like it is standard in other Elixir projects.

While contexts weren't confusing per se for me, I think that the mental overload of requiring user to think of yet another name is problematic, especially when some schemas can be used in multiple contexts.