Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jubianchi/wasmer-php
https://github.com/jubianchi/wasmer-php
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jubianchi/wasmer-php
- Owner: jubianchi
- License: mit
- Created: 2021-01-03T23:48:01.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-08T21:59:28.000Z (almost 4 years ago)
- Last Synced: 2024-10-10T14:18:43.458Z (4 months ago)
- Language: C
- Size: 14.4 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A complete and mature WebAssembly runtime for PHP based on [Wasmer].
**You are seeing the readme for the latest Wasmer Go version, if you are using an older version, please go to:**
* [1.0.0-alpha1][Wasmer]: https://github.com/wasmerio/wasmer
[1.0.0-alpha1]: https://github.com/wasmerio/wasmer-php/tree/1.0.0-alpha1/README.md# 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:
```bash
git clone https://github.com/wasmerio/wasmer-php
cd wasmer-php
phpize
./configure --enable-wasmer
make
make test
make install
```> Note: Wasmer doesn't work on Windows yet.
# Examples
```php
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);
```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 directory][examples].
[examples]: ./examples
# 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][license].[license]: https://github.com/wasmerio/wasmer/blob/master/LICENSE