A First Example
As a first example let's create a
Hello World application.
For this example we'll assume the user is sitting at the CLI of a REX enabled Linux client (called rexclient). The code will be uploaded
onto the server (called codeserver) and published via apache in the directory http://codeserver/rex/
The REX Code
REX code is simply PHP but usually saved with a .rex extension (to stop it being executed by apache when requested).
Here is the sourcecode for our file index.rex:
<?php
echo "Hello World!"
?>
We save this file to the directory published by our codeserver as /rex/ (usually something like /var/www/html/rex in the codeserver file system).
Two key points:
- We name the file index.rex as (unless otherwise configured) REX will look for that file when given a directory as a codebase
- We save the file with a .rex extension not only so REX can find it but also if anyone browses manually to http://codeserver/rex/index.rex it will not be executed by codeserver as PHP (we don't want this - we want it to load into REX and be executed there).
Executing on the REX-enabled client
Now the code has been created and saved onto the codeserver we can request and execute it on the client:
$ php rex.php http://codeserver/rex/
Will start REX and tell it to download the file from http://codeserver/rex/ (because this is a directory it will try the file index.rex in that directory).
Expected Output
$ php rex.php http://codeserver/rex/
Hello World!
$
And there you have it - your first REX application.
Note a similar example (and others) are available hosted at PurplePixie for you to browse online or request via REX. You can find these on the
examples page.