Version: v0.7.1 - Beta.  We welcome contributors & feedback.

PHP Interface


There are two ways to interface with PHP.

Call PHP Libraries From Your THT App 

You can call PHP libraries via the Php Module.

The PHP files should be located in code/php.

They can be executed via Php.require, which uses PHP's require_once function.

// Load 'code/php/myPhpLibrary.php'

// Call a global function
$val ='a_php_function', 'arg1', 'arg2')

// Construct a PHP object
// Namespaces can use '/' instead of '\'
$obj ='Abc/MyClass')


Sideload THT in a Pre-Existing PHP App 

If you have a pre-existing PHP app, you can sideload a THT app to call the modules in it.

First, create a new THT app as normal.

Then you can include THT modules and pages directly.


// Require the THT runtime
$pathToThtApp = 'path/to/thtapp';
require_once($pathToThtApp . '/system/tht/lib/core/ThtSide.php');

// Include a THT module and call its functions
$testMod = Tht::module('TestModule');

// Or run a route and then exit the script.

See Also