From PHP to Elixir?


I just started this week to discover Elixir.
I’m a PHP-Programmer and did some sutff in Go too.
The more I read about Elixir the more I’m intressting and exited about the possibilites that offert this language and it’s libraries (Phoenix, Oban, Ecto … ).

I use a Cli-App in php to import data and for each rows I do some operations on it.
A Job-Scheduler is also used to start this app regularly.

I’m thinking about to write the app in Elixir. Does Elexir feet well for my use case or this use case is more a for Go?
I have 60.000 / Job executions per days which are started by a Scheduler.

Thank you!

60k per day is nothing. I import 1 million records in about ~18 seconds with my Elixir tools. Although I don’t know how much a single task would take in your case.

Elixir per se is not the ideal candidate for CLI tools because the VM starts up slower compared to dedicated statically compiled languages like Go and Rust. But it still works quite fast.

What’s your expected usage of Elixir? A background jobs processor?


Thank you for your answer,

60K was the number of job exeuctions / days ) it could be the same or a diffrent).
Execution could be an import/export or an update (Flows)
A Cli-App is helpfull to check on the output during development process the result of the exeuction.
It give also the flexibility to set some parameter and see (into a scheduler sofware) quickly how the application was started.

How Elixir Applications are started ? Are they started once and run “forever” ?
Does your application look into a specific directory that a file has to be proceed ?

I often deploy a new “version” of the cli-application, that may have correction,improvment ot extension of a buisness logic

I think an usage of Elixir as a background job processor is the way that is close to what I use now.

1 Like

You have a console with Elixir, when You run in a project

$ iex -S mix

You have direct access to your application, and You can debug, recompile in it… It would be like Linux for application, You don’t need to reboot, You just recompile.

Elixir is a language that simplify concurrency, it’s built in.

Nothing stop You to start 60 000 processes, each one responsible for a job.

60_000 is not a high number for processes, but You need to master how to manage them.

OTP is done for this, it’s all about managing correctly processes. You did not mention it, You just mentionned libraries. But it’s included in the BEAM.

If You come from PHP, You will be surprised at the dev tooling offered by Elixir :slight_smile:

You can build script with Elixir.


It might not be the best match for some CLI tools, when your commands are expected to run very fast (few miliseconds), due to the BEAM startup time… but as that doesn’t eat also way too much time (like half a second or less?), it’s perfect for most stuff that is more complex, as that is gonna take a few seconds anyways

In short “Yes”, this is what it is designed for. If you want a CLI tool then I’d say use python or if you need it to run as fast as possible then use rust, but if you need something to live ‘forever’ then use Elixir (which can also slave out to things like Rust very easily for CPU intensive things).

1 Like

what’s about if I have the main core in Elixir and for other cli-purpose a cli in go/rust that can “speak” to the core application ?

I’d like the possibility to have the core in one part and for specific modules.
Modules could be deployed more often then the core.

When stabilizes Elixir should be great for cli tools.

1 Like

There is talk about Lumen here

One of their target after main Webassembly target is to allow creating cli tools with Elixir.

Any particular business reasons of why are you so keen to fragment your app between different languages? And to have a CLI tool even?

I don’t have a particular business reason, it was just a thought how I can improve the Application I have at the moment.
As I have different independents Flows, I’d like the comfort to start one of them from the CLI and to see directly in live (some relevant information are displayed on the output) what the process do. Maybe there is others different possibilities I don’t know about the way to proceed this work.

Thanks for the link, It sounds interesting and promising! :slight_smile:

I like to make either a webpage for that (using drab/liveview) or setup an ssh pipe (the beam comes with an SSH server) so I can just ssh in to it and the server sends back whatever I want it to send back, all authed. :slight_smile:

1 Like

I knew the ssh server was there but I had never tried it. It was surprisingly easy to setup and gets you straight into the node. I wonder if I should just add that in as a standard for my releases from now on.


For note, the built-in default shell gives you node access, but I personally don’t like allowing that for security reasons, so you can make a new ‘shell’ instead to do whatever you want. :slight_smile:

FYI, Elixir/Erlang provides a remote shell with some extremely powerful inspection tools across your whole application. So you may be able to get rid of your CLI tools, and just use the built-in remote shell.

Specifically Fred’s tool is pretty great.

And his book Erlang in Anger is worth a read as well.


Thank you for the link , I will have a look!

The Erlang/Elixir development platform is very great!