Minimal PHP core library for PHP environments.
After getting started with Uniter and PHPRuntime, you might want only a subset of the standard PHP library. You can include PHPCore and then only expose the builtin functions, classes or constants you need.
varphpCore=require('phpcore');phpCore.install({functionGroups: [function(internals){return{'add_one_to': function(argReference){returninternals.valueFactory.createInteger(argReference.getNative()+1);}};}],classes: {'TwentyOne': function(){functionTwentyOne(){}TwentyOne.prototype.getIt=function(){return21;};returnTwentyOne;},'My\\Tools\\Worker': function(){functionWorker(){}Worker.prototype.run=function(){console.log('running');};returnWorker;}},constantGroups: [function(internals){return{'MY_CONSTANT': 1000};}]});phpCore.compile(// Example JS code transpiled from PHP by PHPToJS:function(core){varadd=core.add,callFunction=core.callFunction,createInteger=core.createInteger,getConstant=core.getConstant;returnadd(getConstant('MY_CONSTANT'),callFunction('add_one_to',[createInteger(21)]));})().execute().then(function(result){console.log(result.getNative());// Prints "1022"});- Follow me on Twitter for updates: https://twitter.com/@asmblah