Search code examples
phpelixirstdin

Elixir application runs a PHP script


I'm writing an elixir application that needs to communicate with several APIs.

One api is a connection to Post Affiliate Pro which uses PHP and has a PHP class file you can download to use their API easily.

As I seach for answer online my results are overwhelmed about using PHP to run elixir which is the opposite of wha. I need

I know nothing about PHP, I don't even know what dependencies I'll need on the server to run a php script.

My elixir program currently runs an executable using System.cmd().

Would it be possible to use System.cmd() to run the script file and have the output of the PHP script be routed to elixir's STDIN? I've never done that before but maybe I should start there? Any suggestions?


Solution

  • If its a script designed to be run from the command line, the you should be able to run it with System.cmd/1. First try to run the script manually from the command line and get it working.

    I would start with ensuring that you have php installed on your system. If not, you will need to install it.

    The other option is to use the php script to understand the API its using and create your own in Elixir, using a http client.