How can I write backend with Elixir for web development except Phoenix?

So I have a frontend written in some basic html, css and js. I want some backend with Database (login/register) for my website. Are there any recommended documentation about that how do build that in plain elixir (mix)? Or are there any good started librarys? Thanks in advance.

Try Plug.

4 Likes

I would advice against it since there is no issue in using phoenix as an api only instead of you spending time trying figure out how wire up plug and ecto from scratch.

4 Likes

Though it explicitly addresses serving web pages rather than APIs (the two aren’t so different), you might want to have a read of Saša Jurić’s blog post Phoenix is modular. It’s a nice overview of what libraries constitute Phoenix, how it’s possible to use them individually or strip some out of a Phoenix app, and why despite knowing that you might not want to.

7 Likes

For those who think Phoenix is “heavyweight” here’s a single file exs file that launches a Phoenix-based server (from @Gazler). phoenix.exs · GitHub

18 Likes

Oh I absolutely LOVE this, thanks for posting it!

2 Likes

That is really cool!
I ported it to an Elixir app, to see how it will look like.

Thank you @gazler for creating it and @gregvaughn for sharing it here.

1 Like

If you want to ship content through a websocket like discord you could use cowboy and plug, but that’s only for apps you want to make horridly real time. If you are just implementing a way to do logic and query a database, (and you don’t want to use phoenix), you might just be better off with a firebase app (which still has real-time listeners).

Thank you Greg. Appreciate the contribution

There’s also a book Programming Ecto - it’s dealing with Phoenix only marginally and there’s a whole chapter literally named “Adding Ecto to an Elixir Application Without Phoenix” :slightly_smiling_face: Maybe that could be useful for your purposes too.

2 Likes

but does phoenix only work with postgres?

No, there are a lot of db-adapters.

Absolutely not the case, what gave you that idea? Phoenix doesn’t care about databases. Ecto does. And it can work with a good number of DBs.