
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
@uniter/phpcore
Advanced tools
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.
var phpCore = require('phpcore');
phpCore.install({
functionGroups: [
function (internals) {
return {
'add_one_to': function (argReference) {
return internals.valueFactory.createInteger(argReference.getNative() + 1);
}
};
}
],
classes: {
'TwentyOne': function () {
function TwentyOne() {}
TwentyOne.prototype.getIt = function () {
return 21;
};
return TwentyOne;
},
'My\\Tools\\Worker': function () {
function Worker() {}
Worker.prototype.run = function () {
console.log('running');
};
return Worker;
}
},
constantGroups: [
function (internals) {
return {
'MY_CONSTANT': 1000
};
}
]
});
phpCore.compile(
// Example JS code transpiled from PHP by PHPToJS:
function (stdin, stdout, stderr, tools, namespace) {
var namespaceScope = tools.createNamespaceScope(namespace), namespaceResult, scope = tools.globalScope, currentClass = null;
return tools.valueFactory.createInteger(
namespaceScope.getConstant('MY_CONSTANT').getNative() +
namespaceScope.getFunction('add_one_to')(tools.valueFactory.createInteger(21)).getNative()
);
}
)().execute().then(function (result) {
console.log(result.unwrapForJS()); // Prints "1022"
});
FAQs
Minimal PHP core library for PHP environments
We found that @uniter/phpcore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.