️ WebAssembly runtime for PHP
A complete and mature WebAssembly runtime for PHP based on Wasmer.
wasmer API mimics the standard WebAssembly C API,wasmer executes the WebAssembly modules as fast as possible, close to native speed,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 installNote: Wasmer doesn't work on Windows yet.
Procedural API…Object-oriented API 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:
| Platform | Architecture | Status |
|---|---|---|
| Linux | amd64 |
✅ |
| Linux | aarch64 |
❌ |
| Windows | amd64 |
❌ |
| Darwin | amd64 |
✅ |
| Darwin | aarch64 |
❌ |
| PHP | Status |
|---|---|
| 8.0 | ✅ |
| 7.4 | ❌ |
| 7.3 | ❌ |
| Compiler | Status |
|---|---|
| Cranelift | ✅ |
| LLVM | ❌ |
| Singlepass | ❌ |
| Engine | Status |
|---|---|
| Native | ✅ |
| JIT | ✅ |
| Object File | ❌ |
| Object | Status |
|---|---|
| config | ✅ |
| engine | ✅ |
| store | ✅ |
| Type | Status |
|---|---|
| valtype | ✅ |
| functype | ✅ |
| globaltype | ✅ |
| tabletype | ✅ |
| memorytype | ✅ |
| externtype | ✅ |
| importtype | ✅ |
| exporttype | ✅ |
| Object | Status |
|---|---|
| val | ✅ |
| frame | ✅ |
| trap | ✅ |
| foreign | ✅ |
| module | ✅ |
| func | ✅ |
| global | ✅ |
| table | |
| memory | ✅ |
| extern | ✅ |
| instance | ✅ |
| Feature | Status |
|---|---|
| WAT | ✅ |
| WASI | ❌ |
| Cross Compilation | ❌ |
The entire project is under the MIT License. Please read the
LICENSE file.
No open issues yet, or sync has not completed.