I’m a beginner programmer and I focus on mobile android iOS apps. I’m learning elixir because I’d like to use it to create my real-time group chats app. I’d like to use Pheonix features like channels and pubsub but I’d like if I didn’t need to go all in on using the framework.
I’m focusing on building the api for my mobile app, which can also be used by websites of course. But I’m not interested in things like liveview, so I’d like to know if it’s possible to just add Pheonix to my dependency in my normal mix project and use it like a normal library to get access to things like use Pheonix.Channels where I need them.
Sure, why not?
Pheonix → Phoenix, though.
The key here is framework
which sounds like some parts of the Phoenix
are forced to you, so let’s explain it …
I guess community name it framework for simplicity, so people interested in Phoenix vs Rails
topic would not waste time on finding why Rails
is called a framework and Phoenix
not as it’s usually not something you need to know in the first place.
Elixir
, Phoenix
and many other “core” packages gives lots of flexibility. The easiest argument here is a fact that you can create multiple modules or modules with a different name than file name. The framework on the other hand is forcing some standards often without any alternative.
In most cases it’s “simpler” like when someone is holding your hand. When beginners have too much flexibility it’s obviously nightmare, but it’s also a powerful thing in the “good hands”. What’s the point? Let’s take a look at style guides. In theory Elixir
is hard as it does not even have an official style guide (only simple formatter task). In practice however we have few style guides.
Some people may think that it could only confuse people, but when we read them we find that many rules are very similar if not exactly same. This shows that within a community over many years of practice there are well known standards that exist for a really good purpose and not a maintainers “preference”.
We have a credo
tool and it’s usually well regarded, but never required by the language or a framework. Same goes with everything else. Usually you can rewrite parts of your generated modules (like endpoint or router) while still using for example controllers.
Also other naming may be confusing as well, for example:
-
Library
- for me it sounds like it compiles to.dll
or.so
file that my code is supposed to use -
Hex package
- new developers does not know anything includinghex
, soframework
is easier to get and remember, think that you explain not whatRails
is, but whatgem
means inRuby
. -
Dependency
- this may look good at first, but it’s more complicated than you may think … For example what doesweb dependency
means? It may sounds like a dynamic dependency that would be fetched when needed, right?
Simply web framework
is too common naming to avoid it while alternatives are not good enough for a learning purposes.
Not quite sure what this means
Alright, thanks. Just wanted to know if this is possible
You are mis-spelling Phoenix. It’s not Pheonix, it’s Phoenix.
yes, as mix phx.new
just generates a mix project, if you don’t want database stuff, you can skip ecto relate deps, and if you don’t want liveview you shoudl skip liveview. A pruned deps would look something like:
[
{:phoenix, "~> 1.7.18"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:telemetry_metrics, "~> 1.0"},
{:telemetry_poller, "~> 1.0"},
{:jason, "~> 1.2"},
{:bandit, "~> 1.5"}
]
Thanks. Was thinking live_reload have something to do with live view before