phpcore

8.1.2 • Public • Published

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 (core) {
        var add = core.add, callFunction = core.callFunction, createInteger = core.createInteger, getConstant = core.getConstant;
        return add(getConstant('MY_CONSTANT'), callFunction('add_one_to', [createInteger(21)]));
    }
)().execute().then(function (result) {
    console.log(result.getNative()); // Prints "1022"
});

Keeping up to date

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
8.1.25latest

Version History

VersionDownloads (Last 7 Days)Published
8.1.25
8.1.12
8.1.02
8.0.40
8.0.30
8.0.20
8.0.10
8.0.00
7.2.00
7.1.00
7.0.00
6.2.021
6.1.00
6.0.10
6.0.00
5.12.022
5.11.00
5.10.10
5.10.00
5.9.00
5.8.30
5.8.20
5.8.10
5.8.00
5.7.00
5.6.00
5.5.30
5.5.26
5.5.10
5.5.00
5.4.00
5.3.10
5.3.00
5.2.21
5.2.10
5.2.00
5.1.00
5.0.10
5.0.00
4.19.10
4.19.02
4.18.00
4.17.00
4.16.00
4.15.10
4.15.00
4.14.00
4.13.00
4.12.10
4.12.00
4.11.10
4.11.00
4.10.01
4.9.10
4.9.00
4.8.00
4.7.10
4.7.00
4.6.10
4.6.00
4.5.00
4.4.00
4.3.20
4.3.10
4.3.00
4.2.10
4.2.00
4.1.00
4.0.00
3.21.20
3.21.10
3.21.00
3.20.00
3.19.00
3.18.30
3.18.20
3.18.10
3.18.00
3.17.30
3.17.21
3.17.10
3.17.00
3.16.00
3.15.00
3.14.00
3.13.00
3.12.00
3.11.00
3.10.00
3.9.10
3.9.00
3.8.10
3.8.01
3.7.40
3.7.31
3.7.20
3.7.10
3.7.00
3.6.20
3.6.10
3.6.00
3.5.01
3.4.00
3.3.00
3.2.00
3.1.10
3.1.00
3.0.00
2.1.00
2.0.00
1.4.321
1.4.20
1.4.10
1.4.00
1.3.00
1.2.30
1.2.20
1.2.10
1.2.00
1.1.01
1.0.00

Package Sidebar

Install

npm i phpcore

Weekly Downloads

61

Version

8.1.2

License

MIT

Unpacked Size

4.91 MB

Total Files

790

Last publish

Collaborators

  • asmblah