PHPackages                             flysion/phplua - 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. flysion/phplua

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

flysion/phplua
==============

基于PHP的luac扩展的基础上封装的lua代码库，像写PHP一样的写lua而不用操心GC问题

20PHP

Since Oct 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/flysion/phplua)[ Packagist](https://packagist.org/packages/flysion/phplua)[ RSS](/packages/flysion-phplua/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

flysion/phplua
==============

[](#flysionphplua)

基于PHP扩展（）进行二次封装。特性:

- 解决内存持续增加的问题
- 在LUA中很方便的调用PHP的函数和类方法
- 及时释放PHP内存（利用 lua 的 metatable 特性）
- 解决lua调用php方法抛出异常时，lua代码继续往下执行的问题

使用示例
----

[](#使用示例)

### LUA调用PHP方法

[](#lua调用php方法)

基本用法，需要通过lua的`import`方法导入php方法

```
$lua = new \Flysion\Lua\Lua();
$lua->eval(eval("print(md5('123456'))");
```

*总之，一旦一个PHP变量导入到LUA里边之后你可以像写PHP一样的自由调用这个变量*

错误处理
----

[](#错误处理)

重写`exception`方法

```
$lua = new class() extends \Flysion\Lua\Lua {
    protected function exception(\LuaException $e)
    {
        if(!isset($e->err['__throw__']))
        {
            return $e;
        }

        switch ($e->err['__throw__']) {
            case 2:
                return new Exception2($e->err['message'] ?? "", $e->err['code'] ?? null, $e->err['data'] ?? null);
            default:
                return new Exception($e->err['message'] ?? "", $e->err['code'] ?? null);
        }
    }
};
```

定义lua方法

```
$lua->eval(destroy();
```

or

```
$lua = new \Flysion\Lua\Destructor(
    new \Flysion\Lua\Lua()
);
```

**注意：来自的lua扩展并没有`destroy`方法，需要使用我魔改过的扩展：**

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cbfc6a439ae57c4761a49f67fac37473e742e8e1a3e8276c7dbd79d12594829e?d=identicon)[a328496647](/maintainers/a328496647)

---

Top Contributors

[![flysion](https://avatars.githubusercontent.com/u/4687645?v=4)](https://github.com/flysion "flysion (5 commits)")

### Embed Badge

![Health badge](/badges/flysion-phplua/health.svg)

```
[![Health](https://phpackages.com/badges/flysion-phplua/health.svg)](https://phpackages.com/packages/flysion-phplua)
```

PHPackages © 2026

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