thiagomajesk
Hi! I was wondering if we have something similar to the concept of “areas” in ASP.NET MVC for Phoenix.
It’s nothing really complicated; In its essence, it’s just a folder structure, but ASP.NET generators support the concept of aggregating controllers/ views and routes inside an “area” by default (Please don’t confuse this with Phoenix contexts, “areas” are meant as a web-app-only organization structure).
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
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
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
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
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sync08
I’ve actually just been doing that today. I’m building a new project in both ASP.NET Core and Elixir/Phoenix to see what is a better fit.
I recreated the ASP.NET folder structure for “Areas” and and placed all controllers/channels/views/templates into there. If I remember correctly the biggest issue was that templates were not found by default so what I ended up doing was creating different macros for the controller/view for each area by duplicating the generated ones and changing the default namespace and template location.
I moved all of the default controllers/channels/views/templates into a “shared” area. This also required changing the default controller/view macros.
The Phoenix namespacing is pretty annoying to be honest as the controllers/views e.t.c. aren’t namespaced like most Elixir modules. Controllers and views have to live in the same namespace if you want them to work by convention, even though they’re in separate directories. Stick with “AppWeb.Areas.AreaName.ControllerName” and not “AppWeb.Areas.AreaName.Controllers.ControllerName”.
I decided to reverse my decision and go back to the default structure so everything was just subdirectories in the root controllers/views/templates directories. Mainly because I felt dirty for having a controller/view macro for each area and it’s easier using the generators.
jeremyjh
I wrote about a similar idea awhile back. We found this structure helpful especially for server-rendered apps its easier to navigate if you keep templates with the controller and view. Its very easy to tweak the Phoenix generated macros to customize things the way you want to. And if you don’t have templates, you don’t have to tweak anything if you want to keep your view and controller together.
thiagomajesk
@sync08 So in other words, we would really have to go off the rails for this. In my experience, is always a bad idea to stray too much from a framework defaults if it is really opinionated regarding structure.
@jeremyjh I find that using the term “context” to describe this kind of folder structure in the web app to be misleading because we already use this word to represent application’s domain boundaries, and one thing does not lead to the other - necessarily. What you are presenting is similar to what I’ve used for years with ASP.NET, we call it “feature folders”, which is a vertical sliced folder structure.
tme_317
I think it’s fine to customize your folder structure however you like and it’s not “going off the rails” as Elixir/Phoenix is flexible and doesn’t really care. You can co-locate your templates with your controller and view by making this tweak: Domain-oriented web folder structure with further discussion here: Discussion about domain-orientated folder structures in Phoenix