I am looking for resources on adding phoenix to an existing application.
We have a service that was previously only an API but now has some dashboards. It is currently built without Phoenix but we will probably add it. We have enough existing code that using generators will probably not be helpful.
I’ve heard several people say that it is best to have a decoupled application then add phoenix as needed. For example in this Elixir fountain episode, around 10 minutes in.
Paraphrasing:
Start with business logic, just modules and functions
Add that into a genserver to get parallelism and concurrency.
When you want to make it available on the web as phoenix as a web layer.
So yes any resources that concretely discuss step 3 is what I am after. thanks.
I don’t know if there’s a better way, but here’s a hacky approach I used a couple of months ago for a toy project to Phoenixize an existing OTP app without resorting to umbrella. Let’s say we have a project named foobar and the code is committed to the repo. I did the following steps:
cd /tmp
mix phx.new foobar
copy the entire contents of /tmp/foobar to /working/copy/of/foobar
add all the new files
carefully comb through modified files and reconcile with the latest state in the foobar repo
It’s not perfect, but it wasn’t all that difficult either. IIRC it took me some 20 minutes, and I got it right in the first attempt
I’m curious to learn if there’s a more automated way.
Well no one has suggested one. I though that is what I was going to end up doing. Indeed 20 minutes is not too much time but it feels very unsatisfactory as a solution.