Jaypee

Jaypee

Hi,

I have been learning Elixir and OTP (then also some Erlang as it is in fact mandatory for using both) for several monthes.

I made a small project using them (“a (very) Simple SFTP Client/Server in Elixir” ) which seems to be at least operational.

If my code is surely far from beeing “pure and clean” for Elixir buffs like you, I would like to believe that, after some epic struggles with a lot of books and videos and thanks to some help in this forum, I managed to roughly understand the main principles of the language and OTP.

My next plan is now to learn Phoenix. And then LiveView…

In this goal, I bought the “Programming Phoenix >= 1.4” book (which seems to be the only up-to-date book about the current Phoenix version) and begun to follow the “Rumbl” application exposed as an example/exercice.

But now that I’m at the first third of the book, I’m a bit confused by the massive number of files scattered in so many odd categories such as contexts, controllers, templates, views et al.
And then the questions : how and where should I set my code in this huge tree ? What precisely are these concepts and how do they articulate whith each others ?

So if you could advice some (up-to-date) resources (books, videos, web sites) which could - clearly- explain that for a guy who knows Elixir but who is not familiar with others full stack frameworks such as Ruby On Rails (which seems to be the starting point for Phoenix)… ?

Thanks in advance.

Showing Posts 1 to 4

kokolegorille

kokolegorille

You need to learn about MVC. Obviously there are no models in Phoenix, but that would be Schema and Context.

Most of the time You will put your code in contexts.

LostKobrakai

LostKobrakai

The rough determination is the following:

Context at their core are nothing more than what you did before: Put business logic into modules. This is mostly something special in the context of webframeworks, because people tent to not separate this from the actual code handling specifically webrequests.

Now the code in context cannot yet be called via web requests. This is what your endpoint/router/controllers are for. They receive requests and handle them in various ways. The endpoint is for stuff affecting any requests coming in, the router handles forwarding to controllers based on things like paths or other determinations, while controllers/their actions are there to handle the specific task the request is trying to affect. This could be requesting e.g. a list of users as well as submitting changes. The controller itself should at best only handle logic, which is specific to a http request, like reading params or headers or stuff like that and use functions of your context modules to handle the actual business logic. It’s like a translation from http request to function call of context modules. A good comparison would be a CLI controller, which translates argv input into actual function calls.

The second part of the controller is to respond to the request with data formatted in json/html/…. So the returned values of the context function calls need to be converted. This task is usually delegated to the view layer. The view layer is responsible for converting the retrieved data into the proper binary (or textual) representation for the http response. For markup languages it’s often quite strange to work with elixir code to build the markup, therefore view layers come with templating capabilities, which allow you to mix static markup with dynamic code parts. But e.g. for json data you usually don’t use templates, but you’ll prepare the structure in a native datatype and just convert it at once to a json string. Again the comparison would be a CLI controller calling into an extracted module to convert data into a table for shell output, because you don’t want each controller to implement the table formatting again.

anon73

anon73

I wanted to write a nice post but @LostKobrakai was quicker :smiley: also since you’ve never used any Full Stack framework @kokolegorille has also a good point, in that case I can recommend this page Backend Developer Roadmap: What is Backend Development Because elixir & phoenix have an awesome documentation I will go with that after you gather knowledge what exactly is an Full Stack framework and what are its main parts (MVC, REST etc…)
Keep going, everything takes some time :slight_smile:

Jaypee

Jaypee OP

I forgot to mention that I’m currently a javascript frontend developper (using Vue.js + Vuetify): that’s perhaps what made me interested in LiveView ? :wink:
Your (nice) advices lead me to then reformulate my question:
Do you know some resources (video courses, books or others) which explain in details the “main parts” of a “generic” FS Framework, to go deeper on the main lines given by @LostKobrakai ?

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
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
kpanic
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
nseaSeb
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
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
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
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
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 Top

GenericJam
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
JesseHerrick
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
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews