Socket
Book a DemoInstallSign in
Socket

@uniter/phpcore

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniter/phpcore

Minimal PHP core library for PHP environments

latest
Source
npmnpm
Version
5.2.2
Version published
Maintainers
2
Created
Source

PHPCore

Build Status

Minimal PHP core library for PHP environments.

Who would use this?

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"
});

Keeping up to date

Keywords

php

FAQs

Package last updated on 10 May 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.