Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proof-of-cencept for calling wasm from php - not great, but probably ok as demo/example code? #519

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

davidbuzz
Copy link

@davidbuzz davidbuzz commented Mar 8, 2024

uses https://extism.org/ , and probably not a great example, but since extism claims it can integrate with go/js/node/ocaml/rust/c++/Zed/python/java/ruby/whatever , does that mean that a fully fleshed-out libextism.so might be more powerful/easier than php's FFI module?

https://github.com/extism/extism

Buzz]$ make clean ; make ; sudo make install ; time php extismcpp.php
rm -f extismcpp.so extismcpp.o
sudo rm -f /usr/lib/php/20220829/extismcpp.so
sudo rm -f /etc/php/8.2/cli/conf.d//extismcpp.ini
g++ -Wall -c -O2 -std=c++11 -fpic -o extismcpp.o extismcpp.cpp
g++ -shared -o extismcpp.so extismcpp.o -lphpcpp -lextism
cp -f extismcpp.so /usr/lib/php/20220829
cp -f extismcpp.ini /etc/php/8.2/cli/conf.d/
Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (fallback through xdebug.client_host/xdebug.client_port).
ExtismClass::ExtismClass([no params])
C++ reading wasm...
reading WASM with read_file
done WASM with read_file length:18258
C++ reading wasm done.
calling extism_function_new with hello_world
calling extism_plugin_new with hello function
sending a string to count to count_vowels...
Hello from hello_world C++!
0x7f6785c3535b
hello_world:{"count": 6}[hello output done]
print_plugin_output:{"count": 6}[output done]
count_vowels plugin said:{"count": 6}12
Freeing userdata
------------------------------
LoadWASM count vowels result: {"count": 6}
------------------------------
ExtismClass::__destruct
ExtismClass::~ExtismClass

real	0m0.037s
user	0m0.019s
sys	0m0.019s
@davidbuzz davidbuzz changed the title proof-of-cencept for callign wasm from php - not great, but probably ok as demo/example code? proof-of-cencept for calling wasm from php - not great, but probably ok as demo/example code? Mar 8, 2024
@davidbuzz
Copy link
Author

Please ignore the commit with the binaries in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant