Files
extism/php/example/index.php
zach 7b27d4f883 feat: add extism_plugin_update (#6)
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>
2022-09-09 00:39:57 -06:00

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";
}