PHPackages                             bingo-soft/script - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bingo-soft/script

ActiveProject[Utility &amp; Helpers](/categories/utility)

bingo-soft/script
=================

Scripting API implemented in PHP

1.3.1(2y ago)05711MITPHPPHP ^7.4 || ^8.0

Since Aug 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bingo-soft/script)[ Packagist](https://packagist.org/packages/bingo-soft/script)[ Docs](https://github.com/bingo-soft/script)[ RSS](/packages/bingo-soft-script/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (6)Used By (1)

[![Latest Stable Version](https://camo.githubusercontent.com/4ef533767d72a24bafa8a85bdf8fa1568a1b3c8dc848bb9f5ecd0aaae173c1d3/68747470733a2f2f706f7365722e707567782e6f72672f62696e676f2d736f66742f7363726970742f762f737461626c652e706e67)](https://packagist.org/packages/bingo-soft/script)[![Minimum PHP Version](https://camo.githubusercontent.com/0e9ac047546796cfdbe1423d1f4d91c8f37d2fbb11614a7900bb7686aaa5401f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e342d3838393242462e737667)](https://php.net/)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://opensource.org/licenses/MIT)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0daba232c81e9d68f0741f696312d92f95c122cb6c1534360d8e95bfe5cd1c67/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62696e676f2d736f66742f7363726970742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/bingo-soft/script/?branch=main)

Scripting API
=============

[](#scripting-api)

Scripting API implemented in PHP

Installation
============

[](#installation)

Install library, using Composer:

```
composer require bingo-soft/script

```

Example 1 (using Juel engine)
=============================

[](#example-1-using-juel-engine)

```
$manager = new ScriptEngineManager();
$engine = $manager->getEngineByName("juel");
echo $engine->eval('${1 + 2}'); //prints 3
```

Example 2 (using Juel engine)
=============================

[](#example-2-using-juel-engine)

```
$manager = new ScriptEngineManager();
$engine = $manager->getEngineByName("juel");

$simple = new class () {
    public $propFloat = 1.23;

    public function foo(): int
    {
        return 11;
    }

    public function bar(): int
    {
        return 23;
    }
};
$engine->put("simple", $simple);

echo $engine->eval('${simple.propFloat + 2}'); //prints 3.23
echo $engine->eval('${simple.bar() + simple.foo()}'); //prints 34
```

Example 3. Calculate factorial using Lua module
===============================================

[](#example-3-calculate-factorial-using-lua-module)

```
$manager = new ScriptEngineManager();
$engine = $manager->getEngineByName("lua");
$engine->put('a', 5);

echo  $engine->eval(
