Php.new
Php.new($phpClassName, $arg1, $arg2, ...) -> object
Description
Instantiate a PHP class.
For convenience, you can use forward slashes in place of backslashes for namespace separators.
$obj = Php.new('vendorLibrary/SomeClass', 123) $obj.doSomething()
The object will be returned in a wrapper object for compatibility with THT.
It contains some additional methods to help work around any inconsistencies, such as naming conventions that don’t work with THT.
zCall($methodName, $arg1, $arg2, ...)
: dynamically call a method with the given args.zGet($propertyName)
: dynamically get the value of an object propertyzSet($propertyName, $value)
: dynamically set the value of an object property
$className = 'vendorLibrary/SomeClass' Php.require($className ~ '.php') $obj = Php.new($className) $obj.zGet('SOME_CONSTANT') //= Ex: 123