I used to use virtual environment in python to separate django version but do we have anything similar in phoenix/elixir. I want to install latest phoenix cli for my new project but i still have old project that i want to keep the old cli at the moment.
I am using asdf for managing multiple Erlang/Elixir version.
looooool that package name is legend
Here are step by step instructions for setting up ASDF https://github.com/cogini/elixir-deploy-template#set-up-asdf
but can asdf control phoenix version locally i am kinda of confused
It doesn’t have to, as phoenix is only installed “project local” as a dependency to your application.
Another nice clean solution is using Docker. Then you can also control things like your PostgreSQL (or other RDMS) version, dependencies like imagemagick, AMQP servers, whatever you need. I’ve got a project setup so I just need to run
docker-compose up and everything runs. It can also simplify deployment depending on your production setup.
but i want to have the old 1.2 phoenix cli for global but only v1.3 for the new project which i think is not local right
i may try that as well but thinking if there easier way than docker xD
i was able to do it now thank you
Aside from me not understanding why one would do that, in fact that’s a bit harder.
I think the easiest way to achieve that is to install the 1.3 version of the project generator, use it to create the project and then replace it again with the 1.2 version.
Alternatively use elixir 1.6.x for older phoenix generator and elixir 1.6.x-git for the new one.
awww I was having a few production project that was run in 1.2 and there still many sudden feature that need to be updated but I am also want to install phoenix 1.3 so that i can migrate all those old project but during the migration process i still want to keep update the 1.2 project to production so that why i want to separate it so that it won’t affect each other. but thank you for your answer
When you are in a project, all tasks are run from the project.
Unless you want to generate a new phoenix app that uses 1.2, there is no need to keep the old
The thing you install from phoenix is just the
mix phx.new task (alternatively the old
mix phoenix.new one as well). Everything else is in the package and is vendored into the
deps folder of each project. There’s no need for reinstalling anything unless you constantly generate new projects in different phoenix versions.
yes you right i guess i was so rely on the generator and the new 1.3 is focus on context while the old one was not. and i guess i was just over thinking i can just manually add new model and stuff without the cli and instead over complicated stuff for simple thing. but i guess at least i learn some thing new hahaha thank you both for your time
Again, if you are in a phoenix 1.2 project and do
mix phoenix.gen.whatever it will use the generators of the recently pulled phoenix 1.2.
If you are in a phoenix 1.3 project and do
mix phx.gen.whatever it will use the generators of the recently pulled phoenix 1.3.
This would even work if if 1.3 were still using
phoenix as a prefix for its tasks.
This does work independently of the installed version of
phx_gen, even if it were for phoenix 1.0 or earlier.
Awww I see thank you for clarify this. I was kinda still very noob with mix and elixir. Now I am fully understand now