mirror of
https://github.com/extism/extism.git
synced 2026-04-23 03:00:11 -04:00
- Adds `ExtismContext` instead of global `PLUGINS` registry - Adds `extism_context_new`, `extism_context_free` and `extism_context_reset` - Requires updating nearly every SDK function to add context parameter - Renames some SDK functions to follow better naming conventions - `extism_plugin_register` -> `extism_plugin_new` - `extism_output_get` -> `extism_plugin_output_data` - `extism_output_length` -> `extism_plugin_output_length` - `extism_call` -> `extism_plugin_call` - Updates `extism_error` to return the context error when -1 issued for the plug-in ID - Adds `extism_plugin_free` to remove an existing plugin - Updates SDKs to include these functions - Updates SDK examples and comments Co-authored-by: Steve Manuel <steve@dylib.so>
18 lines
497 B
PHP
18 lines
497 B
PHP
<?php
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
$ctx = new \Extism\Context();
|
|
$wasm = file_get_contents("../../wasm/code.wasm");
|
|
$plugin = new \Extism\Plugin($ctx, $wasm);
|
|
|
|
$output = $plugin->call("count_vowels", "this is an example");
|
|
$json = json_decode(pack('C*', ...$output));
|
|
echo "Vowels counted = " . $json->{'count'} . PHP_EOL;
|
|
|
|
$wasm = file_get_contents("../../wasm/code.wasm");
|
|
$ok = $plugin->update($wasm);
|
|
if ($ok) {
|
|
$id = $plugin->getId();
|
|
echo "updated plugin: $id";
|
|
} |