X
1711

IDL on the Web with PHP for Windows

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

In short, IDL will execute an IDL sav file that will, in turn, execute a direct graphic plot routine and generate a 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 Code Contribution contains 9 attached files compressed into the file "IDLonWeb.zip"
===========================================================

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 attached file called "Windows Environment Path Variable.PNG" for more details on how to achieve that.



2- Apache Server Configuration

Using the Web Server application called XAMPP, 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. See attached screen shot "Apache  
Webserver XAMPP.PNG" for more details.



3- IDL and PHP program examples

The example consists of four files. This 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\" I have created a folder called "idl".  
Under that folder I 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: 
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

See screen shot "XAMPP htdocs directory.PNG"



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 screen shot "Example PHP output.PNG".


Notes

Screen shot file names included with this examples are:

Windows Environment Path Variable.PNG
Apache Webserver XAMPP.PNG
Example PHP output.PNG
XAMPP htdocs directory.PNG