All Projects β†’ wasmerio β†’ Wasmer Php

wasmerio / Wasmer Php

Licence: mit
πŸ˜πŸ•ΈοΈ WebAssembly runtime for PHP

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Wasmer Php

Raylib
A simple and easy-to-use library to enjoy videogames programming
Stars: ✭ 8,169 (+926.26%)
Mutual labels:  wasm, webassembly
Ssvm
SSVM is a high performance, extensible, and hardware optimized WebAssembly Virtual Machine for cloud, AI, and blockchain applications.
Stars: ✭ 751 (-5.65%)
Mutual labels:  webassembly, wasm
Zwitterion
A web dev server that lets you import anything*
Stars: ✭ 514 (-35.43%)
Mutual labels:  webassembly, wasm
Awesome Wasm Runtimes
A list of webassemby runtimes
Stars: ✭ 490 (-38.44%)
Mutual labels:  webassembly, wasm
Astro
A fun safe language for rapid prototyping and high performance applications
Stars: ✭ 588 (-26.13%)
Mutual labels:  webassembly, wasm
Uno
Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
Stars: ✭ 6,029 (+657.41%)
Mutual labels:  webassembly, wasm
Awesome Wasm
😎 Curated list of awesome things regarding WebAssembly (wasm) ecosystem.
Stars: ✭ 6,377 (+701.13%)
Mutual labels:  webassembly, wasm
Camaro
camaro is an utility to transform XML to JSON, using Node.js binding to native XML parser pugixml, one of the fastest XML parser around.
Stars: ✭ 438 (-44.97%)
Mutual labels:  webassembly, wasm
Webassemblyjs
Toolchain for WebAssembly
Stars: ✭ 566 (-28.89%)
Mutual labels:  webassembly, wasm
Dotnet Webassembly
Create, read, modify, write and execute WebAssembly (WASM) files from .NET-based applications.
Stars: ✭ 535 (-32.79%)
Mutual labels:  webassembly, wasm
Genact
πŸŒ€ A nonsense activity generator
Stars: ✭ 5,109 (+541.83%)
Mutual labels:  webassembly, wasm
Pib
PHP in Browser (powered by WebAssembly)
Stars: ✭ 649 (-18.47%)
Mutual labels:  webassembly, wasm
Wasm And Rust
WebAssembly and Rust: A Web Love Story
Stars: ✭ 476 (-40.2%)
Mutual labels:  webassembly, wasm
Graphql Client
Typed, correct GraphQL requests and responses in Rust
Stars: ✭ 620 (-22.11%)
Mutual labels:  webassembly, wasm
Asmble
Compile WebAssembly to JVM and other WASM tools
Stars: ✭ 466 (-41.46%)
Mutual labels:  webassembly, wasm
Vim.wasm
Vim editor ported to WebAssembly
Stars: ✭ 4,915 (+517.46%)
Mutual labels:  webassembly, wasm
Ink
Parity's ink! to write smart contracts
Stars: ✭ 407 (-48.87%)
Mutual labels:  webassembly, wasm
Jwebassembly
Java bytecode to WebAssembly compiler
Stars: ✭ 426 (-46.48%)
Mutual labels:  webassembly, wasm
Wasmtime
Standalone JIT-style runtime for WebAssembly, using Cranelift
Stars: ✭ 6,413 (+705.65%)
Mutual labels:  webassembly, wasm
Wasm Loader
✨ WASM webpack loader
Stars: ✭ 604 (-24.12%)
Mutual labels:  webassembly, wasm
Wasmer logo

Wasmer PHP

Tests Status Nightly Status License

Website β€’ Docs β€’ Slack Channel


A complete and mature WebAssembly runtime for PHP based on Wasmer.

Features

  • Easy to use: The wasmer API mimics the standard WebAssembly C API,
  • Fast: wasmer executes the WebAssembly modules as fast as possible, close to native speed,
  • Safe: All calls to WebAssembly will be fast, but more importantly, completely safe and sandboxed.

Install

To install the library, follow the classical:

git clone https://github.com/wasmerio/wasmer-php
cd wasmer-php/ext
phpize
./configure --enable-wasmer
make
make test
make install

Note: Wasmer doesn't work on Windows yet.

Examples

Procedural API
<?php 

declare(strict_types=1);

$engine = wasm_engine_new();
$store = wasm_store_new($engine);
$wasm = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'hello.wasm');
$module = wasm_module_new($store, $wasm);

function hello_callback() {
    echo 'Calling back...' . PHP_EOL;
    echo '> Hello World!' . PHP_EOL;

    return null;
}

$functype = wasm_functype_new(new Wasm\Vec\ValType(), new Wasm\Vec\ValType());
$func = wasm_func_new($store, $functype, 'hello_callback');
wasm_functype_delete($functype);

$extern = wasm_func_as_extern($func);
$externs = new Wasm\Vec\Extern([$extern]);
$instance = wasm_instance_new($store, $module, $externs);

wasm_func_delete($func);

$exports = wasm_instance_exports($instance);
$run = wasm_extern_as_func($exports[0]);

wasm_module_delete($module);
wasm_instance_delete($instance);

$results = wasm_func_call($run, new Wasm\Vec\Val());

wasm_store_delete($store);
wasm_engine_delete($engine);
Object-oriented API
<?php

declare(strict_types=1);

use Wasm;

require_once __DIR__.'/../vendor/autoload.php';

$engine = Wasm\Engine::new();
$store = Wasm\Store::new($engine);

$wasm = file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'hello.wasm');

$module = Wasm\Module::new($store, $wasm);

function hello_callback()
{
    echo 'Calling back...'.PHP_EOL;
    echo '> Hello World!'.PHP_EOL;

    return null;
}

$functype = Wasm\Functype::new(new Wasm\Vec\ValType(), new Wasm\Vec\ValType());
$func = Wasm\Module\Func::new($store, $functype, 'hello_callback');

$extern = $func->asExtern();
$externs = new Wasm\Vec\Extern([$extern->inner()]);
$instance = Wasm\Module\Instance::new($store, $module, $externs);

$exports = $instance->exports();
$run = $exports[0]->asFunc();

$args = new Wasm\Vec\Val();
$results = $run($args);

This example covers the most basic Wasm use case: we take a Wasm module (in its text representation form), create an instance from it, get an exported function and run it.

You can go through more advanced examples in the dedicated directories:

Supported platforms and features

Platforms

Platform Architecture Status
Linux amd64 βœ…
Linux aarch64 ❌
Windows amd64 ❌
Darwin amd64 βœ…
Darwin aarch64 ❌
PHP Status
8.0 βœ…
7.4 ❌
7.3 ❌

Features

Compilers and engines

Compiler Status
Cranelift βœ…
LLVM ❌
Singlepass ❌
Engine Status
Native βœ…
JIT βœ…
Object File ❌

Runtime

Object Status
config βœ…
engine βœ…
store βœ…

Types

Type Status
valtype βœ…
functype βœ…
globaltype βœ…
tabletype βœ…
memorytype βœ…
externtype βœ…
importtype βœ…
exporttype βœ…

Objects

Object Status
val βœ…
frame βœ…
trap βœ…
foreign βœ…
module βœ…
func βœ…
global βœ…
table πŸ§‘β€πŸ’»
memory πŸ§‘β€πŸ’»
extern βœ…
instance βœ…

Misc

Feature Status
WAT βœ…
WASI ❌
Cross Compilation ❌

License

The entire project is under the MIT License. Please read the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].