English / Русский
version 1.0.0, created by JPPM.
GraalVM JavaScript API
jppm add jphp-graaljs-ext@1.0.0
Classes
<?php
Class ExtClass {
$id = 123;
$text = 'Hello Jphp';
public function test(){
return "jphp string";
}
}
?>
<?php
$Context = new Context();
$newContext = $Context->newBuilder([])->allowAllAccess(true)->build();
$newContext->getBindings("js")->putMember("ExtClass", new ExtClass());
$newContext->eval("js","print(ExtClass.getValue('id'));");
$newContext->eval("js","ExtClass.setValue('id', 1000);");
$newContext->eval("js","print(ExtClass.getValue('id'));");
$newContext->eval("js","let func = ExtClass.invoke('test'); print(func);");
?>