X
67 Rate this article:
No rating

INTERNAL/REVIEW: IDL on the Web with PHP for Windows

Zachary Norman

[Needs to be reviewed for Compliance and IP issues (i.e. save file included)]

This PHP and IDL example codes will execute an IDL command and show the results in a browser webpage under MS Windows.

The idea behind this example PHP code is to show how to interact with IDL and a webpage, in other words, how to have IDL on the Web.

In short, IDL will execute an IDL save file that will, in turn, execute a direct graphic plot routine and generate an image as the output of the plot, and a text file with some information of the plot. Those two files, the image file (JPG) and the text file, will be read back by the PHP and shown using HTML tags, on the webpage.

This Example contains 9 attached files compressed into the file "IDLonWeb.zip". Please, download compressed zip file containing the necessary codes to run this example from:


Discussion
IDL on the Web with PHP for Windows

Index
1- Setting the Environment
2- Apache Server Configuration
3- IDL and PHP program examples
4- Executing the PHP file


1- Setting the Environment

In Windows you will need to configure or set the PATH environment variable so that the following IDL path is included in it:

C:\Program Files\ITT\IDL\IDL81\bin\bin.x86

Please, see the screen shot below:




2- Apache Server Configuration

Using the Web Server application XAMPP 1.7.4, that is available to download from:

http://www.apachefriends.org/en/xampp-windows.html

will allow you to run the Apache Server.

Please, install XAMPP and then Start the Apache Module. You can see an example of the webserver running in the following screen shot:





3- IDL and PHP program examples

The example consists of four files. These files are:

index.php
idlweb1.sav
idlweb1.pro
makefile.pro


-------------------------------------------------------------------------------------------------------------------
index.php:
This is the main PHP program. You will need to edit it to be sure that the user variables are pointing to the right places. For example, in the section of the index.php file you can find:

/////////////////////////////////
//// USER VARIABLES ////////////
$savfile = "C:\\xampp\\htdocs\\idl\\idlweb1.sav";
$path = "C:\\xampp\\htdocs\\idl";
/////////////////////////////////

As you can see the Apache server program XAMPP is installed under C:\. Then, under "htdocs" folder we have created a folder called "idl". Under that folder we copied the "index.php" file plus the "idlweb1.sav" file that will be executed by a called to IDL runtime:

$command = "idlrt.exe $savfile -args $path $fileimg $filetext $npoints";

-------------------------------------------------------------------------------------------------------------------
idlweb1.sav:
The save file that IDL will execute, see line above.

-------------------------------------------------------------------------------------------------------------------
idlweb1.pro:
The actual IDL pro code that produces the plot and the text output.

-------------------------------------------------------------------------------------------------------------------
makefile.pro:
This is the source code for the example described above. You can run this pro code to produce the save file, but this is not needed.
-------------------------------------------------------------------------------------------------------------------

To set everything up just copy the files:

index.php
idlweb1.sav


into the XAMPP folder:

C:\xampp\htdocs\idl

For example, please take a look at the following screen shot:





4- Executing the PHP file

Now that everything is in place, you can open a web browser and type:

http://localhost/idl/index.php

You can then select a value for the number of points to be plotted, e.g. 100, and the PHP code will execute IDL and show what you see in the following screen shot: