Using the Framework API
You can access REX and use it directly in your own client-side code via the API.
The executor that ships with REX (rex.php) should provide a fairly good example of how you can use REX from code.
Include the REX Framework and Instantiate the Object
<?php
include("rex.inc.php");
$REX = new REX();
?>
This will include the framework code and create a REX object ($REX).
REX Properties
- $Base (string)
Base directory to be used for execution (if left blank it will be automatically assigned as the directory of the first codefile executed)
- $Error (bool)
Indicates an error has been encountered
- $ErrorList (array[ string ])
Textual list of errors encountered
- $Quiet (bool)
If set do not show parsing errors (default false)
- $Blocks (int)
Size of blocks to fetch from remote files (default 4096)
- $Default (string)
File to try and load if a directory is passed to execute (defaults to index.rex)
- $Env (array[ mixed ])
Array of environment variables (best not to operate on directly - use the methods)
- $Var (array[ mixed ])
Array of stack variables (best not to operate on directly - use the methods)
REX Methods
- mixed REX::Get( variable[string] )
Get the named variable from the stack (returns false if not found)
- null REX::Set( variable[string], value[mixed] )
Set the named variable in the stack to the value passed
- null REX::EnvLoadArray( array[array], optional name[string] )
Loads an array into the environment variables. If a name is passed the array is loaded under that name, if no name then the array is processed and each key in it is loaded into the environment variables as its own variable.
- null REX::EnvLoadHTTP()
Load common HTTP environment arrays ($_SERVER, $_COOKIE, $_REQUEST, $_GET and $_POST) into REX environment variables under the name _SERVER etc.
- null REX::EnvLoad( variable[string], value[mixed] )
Load a named variable into the environment variables with the value specified
- bool REX::Exec( filename[string] )
Fetch and execute filename (note this is the correct method for calls from the API, not REX::ExecFile() which is used from within REX code). Returns true if that file has executed without errors.
- bool REX::ExecFile( filename[string] )
Fetch and execute file, to be used in REX code not the API (the API call is REX::Exec())