You can also pass function object as argument of LuaSandboxFunction::call():
$lua = new LuaSandbox();
$phpLuaFunction = $lua->wrapPhpFunction(function ($arg){
echo "LUA> ".$arg;
});
$lua->loadString("print = ...")->call($phpLuaFunction);
$lua->loadString('
print("print test from lua\\n")
')->call();
result:
LUA> print test from lua