noccylabs/lua-runtime (0.1.5.3)
Published 2026-04-17 13:25:50 +00:00 by noccy
Installation
{
"repositories": [{
"type": "composer",
"url": "https://dev.noccylabs.info/api/packages/noccylabs/composer"
}
]
}composer require noccylabs/lua-runtime:0.1.5.3About this package
Lua interpreter written entirely in PHP (based on raudius/luar)
Luar
LuaRuntime is a fork of Luar that has been updated for newer versions of PHP (8.4+). The most recent release of Luar (v0.1.4) required PHP 8.0 due to constraints in the ANTLR runtime library.
Luar is a Lua interpreter written in PHP.
Luar implements a reduced version of Lua and also packages some essential Lua libraries. As such Luar offers forward-compatibility with Lua with some minor caveats:
- The math/string libraries use PHP number/string handling; much of the edge-case behaviour has not been replicated (e.g. division by zero, integer overflow)
- Not all core functions and libraries are available, but a method is provided to inject your own
- Some language constructs are not implemented (e.g. variable attributes, go-to statements)
Installation
composer require noccylabs/lua-runtime
Usage
For more details read the documentation.
use NoccyLabs\LuaRuntime\Luar;
$luar = new Luar();
$luar->assign('world', 'Moon');
$luar->assign('hello_world', function ($name='world') {
return "Hello, $name!";
});
$program = '
local greeting = hello_world(world)
print(greeting)
return greeting
';
$greeting = $luar->eval($program);
Note
LuaRuntime is forked from Luar, and the credits should go to the original author, Raul Ferreira Fuentes.
Dependencies
Dependencies
| ID | Version |
|---|---|
| antlr/antlr4-php-runtime | ^0.9.0 |
| ext-json | * |
| php | ^8.0 |
Development Dependencies
| ID | Version |
|---|---|
| clean/phpdoc-md | ^0.19.3 |
| phpunit/phpunit | ^9.5 |