kambo/webassembly 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

Latest Version on Packagist Tests Total Downloads

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
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: C

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固