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

PHP Interface


There are two ways to interface with PHP.

Calling PHP from THT 

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')


Calling THT from PHP 

If you have a pre-existing PHP app that you want to add THT pages to, you can sideload THT.

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