PHPackages                             issadicko/kodi-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. issadicko/kodi-script

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

issadicko/kodi-script
=====================

A lightweight, embeddable scripting language for PHP applications

v0.1.1(4mo ago)00MITPHPPHP &gt;=8.1CI passing

Since Jan 4Pushed 4mo agoCompare

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

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

KodiScript PHP SDK
==================

[](#kodiscript-php-sdk)

[![Latest Stable Version](https://camo.githubusercontent.com/0d1b2b561e764561833ba188355292ad7d7a8eaa48b38067558d2c26071abf7c/68747470733a2f2f706f7365722e707567782e6f72672f697373616469636b6f2f6b6f64692d7363726970742f76)](https://packagist.org/packages/issadicko/kodi-script)[![License](https://camo.githubusercontent.com/fb6781bc2c587a7c2109ca125a31eaa225fdaa66c2fe63fb11d93ff4d4be425b/68747470733a2f2f706f7365722e707567782e6f72672f697373616469636b6f2f6b6f64692d7363726970742f6c6963656e7365)](https://packagist.org/packages/issadicko/kodi-script)[![CI](https://github.com/issadicko/kodi-script-php/actions/workflows/ci.yml/badge.svg)](https://github.com/issadicko/kodi-script-php/actions/workflows/ci.yml)

A lightweight, embeddable scripting language for PHP applications.

📖 **Documentation complète** : [docs-kodiscript.dickode.net](https://docs-kodiscript.dickode.net/)

Installation
------------

[](#installation)

```
composer require issadicko/kodi-script
```

Quick Start
-----------

[](#quick-start)

```
use KodiScript\KodiScript;

// Simple evaluation
$result = KodiScript::eval('2 + 3 * 4');
echo $result; // 14

// With variables
$result = KodiScript::run('greeting + ", " + name + "!"', [
    'greeting' => 'Hello',
    'name' => 'World',
]);
echo $result->value; // "Hello, World!"

// Capture output
$result = KodiScript::run('
    let items = ["apple", "banana", "cherry"]
    for (item in items) {
        print(item)
    }
');
print_r($result->output); // ["apple", "banana", "cherry"]
```

Features
--------

[](#features)

- **Variables**: `let x = 10`
- **Functions**: `fn(a, b) { return a + b }`
- **Control Flow**: `if`, `else`, `for-in`, `while`
- **Data Types**: numbers, strings, booleans, arrays, objects
- **Null Safety**: `?.` (safe access), `?:` (elvis operator)
- **50+ Native Functions**: string, math, random, type, array, JSON, encoding, crypto, date/time

🔌 Extensibility
---------------

[](#-extensibility)

KodiScript is designed to be **extensible**. You can add your own native functions.

### Custom Functions

[](#custom-functions)

```
$result = KodiScript::builder('greet("PHP")')
    ->registerFunction('greet', fn($name) => "Hello, $name!")
    ->execute();

echo $result->value; // "Hello, PHP!"
```

### Laravel Integration Example

[](#laravel-integration-example)

```
class ScriptService
{
    public function __construct(
        private UserRepository $userRepo,
        private NotificationService $notifications
    ) {}

    public function execute(string $script, array $context): ScriptResult
    {
        return KodiScript::builder($script)
            ->withVariables($context)
            ->registerFunction('fetchUser', fn($id) => $this->userRepo->find($id))
            ->registerFunction('sendEmail', fn($to, $subject, $body) =>
                $this->notifications->sendEmail($to, $subject, $body))
            ->registerFunction('calculatePrice', fn($qty, $price, $discount = 0) =>
                $qty * $price * (1 - $discount / 100))
            ->execute();
    }
}
```

API Reference
-------------

[](#api-reference)

### `KodiScript::eval(source, variables)`

[](#kodiscriptevalsource-variables)

Evaluates a script and returns the result value. Throws on error.

### `KodiScript::run(source, variables)`

[](#kodiscriptrunsource-variables)

Runs a script with optional variables and returns `ScriptResult`.

### `KodiScript::builder(source)`

[](#kodiscriptbuildersource)

Creates a builder for advanced configuration.

Native Functions
----------------

[](#native-functions)

CategoryFunctionsString`toString`, `toNumber`, `length`, `substring`, `toUpperCase`, `toLowerCase`, `trim`, `split`, `join`, `replace`, `contains`, `startsWith`, `endsWith`, `indexOf`Math`abs`, `floor`, `ceil`, `round`, `min`, `max`, `pow`, `sqrt`, `sin`, `cos`, `tan`, `log`, `log10`, `exp`Random`random`, `randomInt`, `randomUUID`Type`typeOf`, `isNull`, `isNumber`, `isString`, `isBool`Array`size`, `first`, `last`, `reverse`, `slice`, `sort`, `sortBy`JSON`jsonParse`, `jsonStringify`Encoding`base64Encode`, `base64Decode`, `urlEncode`, `urlDecode`Crypto`md5`, `sha1`, `sha256`Date/Time`now`, `date`, `time`, `datetime`, `timestamp`, `formatDate`, `year`, `month`, `day`, `hour`, `minute`, `second`, `dayOfWeek`, `addDays`, `addHours`, `diffDays`Other Implementations
---------------------

[](#other-implementations)

LanguagePackage**Kotlin**[Maven Central](https://central.sonatype.com/artifact/io.github.issadicko/kodi-script)**Go**[pkg.go.dev](https://pkg.go.dev/github.com/issadicko/kodi-script-go)**Dart**[pub.dev](https://pub.dev/packages/kodi_script)**TypeScript**[npm](https://www.npmjs.com/package/@issadicko/kodi-script)License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance75

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

133d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ca7a812b79182f41ed054174e05e59881d4761a4eb31f253aed8933d76b94f1?d=identicon)[issadicko](/maintainers/issadicko)

---

Top Contributors

[![dickode78](https://avatars.githubusercontent.com/u/168856343?v=4)](https://github.com/dickode78 "dickode78 (8 commits)")

---

Tags

languageparserexpressionDSLscriptsandboxscriptingembeddedinterpreter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/issadicko-kodi-script/health.svg)

```
[![Health](https://phpackages.com/badges/issadicko-kodi-script/health.svg)](https://phpackages.com/packages/issadicko-kodi-script)
```

###  Alternatives

[behat/gherkin

Gherkin DSL parser for PHP

1.1k176.3M97](/packages/behat-gherkin)[nxp/math-executor

Simple math expressions calculator

2281.7M7](/packages/nxp-math-executor)[madorin/matex

PHP Mathematical expression parser and evaluator

1161.2M1](/packages/madorin-matex)[chriskonnertz/string-calc

StringCalc is a PHP calculator library for mathematical terms (expressions) passed as strings.

102643.3k5](/packages/chriskonnertz-string-calc)[corveda/php-sandbox

A PHP library that can be used to run PHP code in a sandboxed environment

23483.5k2](/packages/corveda-php-sandbox)[denissimon/formula-parser

Parsing and evaluating mathematical formulas given as strings.

81306.8k3](/packages/denissimon-formula-parser)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
