Elixir application runs a PHP script - php

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?

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.

Related

PHP ImageMagick script not working when executed via command line

I have a PHP script I'm trying to execute via the command line using the exec() function and I'm getting errors saying PHP can't locate the various classes that are part of the PHP ImageMagick extension (PECL is what I'm using) but it is installed correctly and works fine when running other scripts that use it via the browser.
I'm executing my code this way to create multiple instances and essentially cause parallel processing by allowing Linux to optimize the various processes across my CPU cores on its own. It works great for all the other things I use it for, but not in this situation.
Do I need to change how I installed Imagemagick?
PECL Extension was missing from CLI INI File. Apparently there are two of those files, on for browser execution and another for command line interface.

Run a C++ Application on a Webserver with WordPress

I have a C++-library (.so) for some calculations that I would like to call from Wordpress/PHP via an input formular. The promising idea to build the .so-library as a PHP extension using PHP-CPP has been fine locally on Ubuntu 14.04. But on the webserver this method failed because my webhoster doesn't support changing the extension directive in the php.ini/.user.ini. I see the following alternatives:
Build an exutable application and run it from PHP via proc_open() and send a lot of variables to the stdin of the application. Wordpress itself offers PHP plugins.
Redirect to another server where my own php extensions are supported.
Is there a way using python/web2py for that purpose?
Which would be best?
Or any other ideas?
Probably the simplest way is to create command line utility in C++ and execute it from php with shell_exec. I tried that in past and the performance was not too bad.
"Probably the simplest way is to create command line utility in C++ and execute it from php with shell_exec. I tried that in past and the performance was not too bad."
This did help. Finally I managed a build on Linux which was portable to the webserver where the website and wordpress are located. The call to the binary built from C++ was done with shell exec or popen in PHP (which one I don't remember, it was in 2018). The PHP code was finally migrated to an own wordpress plugin. Unforunately, I could not use PHP-CPP due to missing admin rights for the webderver. But the integration via shell exec or popen works fine.

Integrate python code with php in apache web server without using exec command

I have modules written in python. And I am running my webserver through php apache server. For invoking the existing python scripts, I'm using the following command and this works fine,
shell_exec("python.exe file.py args");
Is there a proper way apart fro doing shell_exec / exec comnand from php.
There are two ways to do that.
Integrate Python into PHP. PHP supports C extensions while Python has libpython. I do not know if such extension exists. This approach doesn't require additional processes to start, but it is total madness.
Run Python script as a service and instead of shell_exec() call some REST API (or whatever). This approach requires additional entities such as services, sockets, but it seem to be architecturally correct.

Using Selenium RC with PHP without terminal?

I am looking into using Selenium RC with PHP but so far, all examples require that you use the terminal to run the php script. Isn't it possible to just run the php file and selenium code without access to terminal?
It is possible, as long as the PHP program is allowed to make remote HTTP requests to the Selenium RC.
But you might need to adjust the maximum execution time if needed:
Reference: http://www.linuxask.com/questions/set-the-maximum-execution-time-in-php

Unable to create sample application using Yii Framework

I am new to PHP. downloaded "yii-1[1].1.4.r2429.zip" file. and try to create sample application using Yii PHP framework
Extracted yii-1[1].1.4.r2429.zip to this path.
C:\xampp\htdocs\yii on windows
and try to create sample application using this guidelines
http://www.yiiframework.com/doc/guide/quickstart.first-app
Run yiic on the command line as follows:
not working.
Please help
Double check that you have PHP CLI (command line) installed and added to your Windows path.
Also, make sure you are running yiic.bat - the Windows script. The plain yiic script (no file extension) is a Unix shell script. You want something like this on Win:
YiiRoot/framework/yiic.bat webapp WebRoot/testdrive
If the .bat script doesn't work, call PHP directly to yiic.php, like so:
php path\to\yii\framework\yiic.php webapp path\to\www\ApplicationName
Your might be able to benefit from XAMPP. It comes pre-packaged and sets up a isolated environment for you, that way you don't have to go through installing php, apache and mysql.

Categories