mirror of
https://github.com/extism/extism.git
synced 2026-04-23 03:00:11 -04:00
This gives host the ability to re-use plugin descriptors instead of loading a new plugin each time. The plugin memory and everything is reset, so no state is shared with the newly loaded plugin. Co-authored-by: Steve Manuel <steve@dylib.so>
17 lines
461 B
PHP
17 lines
461 B
PHP
<?php
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
$wasm = file_get_contents("../../wasm/code.wasm");
|
|
$plugin = new \Extism\Plugin($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";
|
|
} |