kambo/webassembly
最新稳定版本:v0.1.0-alpha.1
Composer 安装命令:
composer require kambo/webassembly
包简介
Run web assembly in PHP
关键字:
README 文档
README
An quick POC (done in ~3 hours) for running WebAssembly modules using Wasmer.
Installation
You can install the package via composer:
composer require kambo/webassembly
Usage
Please see the examples directory for usage examples.
$engine = new Kambo\WebAssembly\Engine(); $store = new Kambo\WebAssembly\Store($engine); // Example WAT (WebAssembly Text) code $wat = '(module (func $sum (param i32 i32) (result i32) local.get 0 local.get 1 i32.add) (export "sum" (func $sum)))'; $wasmBytes = WasmerFFI::watToWasm($wat); $module = new Module($store, $wasmBytes); $instance = new Instance($store, $module); $args = Collection::from([10, 32], Value::KIND_I32); $result = $instance->callFunction('sum', $args); echo $result[0]->asI32(); // Outputs: 42
Current limitations
- 🔧 Needs FFI extension to be enabled.
- ⚠️ Just a POC, can segfault at any moment.
- 🧹 It's probably leaking memory.
- 📦 Wasmer runtime is bundled with the library - not a good idea for production.
- ⚡ Limited support for some WebAssembly features.
- 🍎 Does not support Mac OS (I forget password to my Mac ).
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-11