wasmerio / wasmer-php

🐘🕸️ WebAssembly runtime for PHP
https://wasmerio.github.io/wasmer-php/wasm/
MIT License
1.01k stars 42 forks source link

Possibility to integrate Rust Cassandra client into PHP #86

Closed dbalabka closed 4 years ago

dbalabka commented 5 years ago

Hello,

Recently, I have faced a problem that official PHP Cassandra Client isn't maintained well and does not support PHP >=7.3. The idea might sound crazy but still. Is it possible to compile https://crates.io/crates/cdrs into WASM binary, use inside PHP and rely on such client on production? Also, what is the cost and limitations of using php-ext-wasm?

Thanks in advance!

Hywan commented 5 years ago

The idea isn't crazy. You need WASI support so that you will have access to the network and I/O stack. We have been working on it very recently, and it will come in the next release of php-ext-wasm.

dbalabka commented 5 years ago

@Hywan thank you for an answer. Currently, I am reviewing two options:

  1. Compile Rust client into WASM
  2. or connect it with PHP FFI.

Am I'm right that WASM extension has it own some FFI layer to convert types? Not sure, but I guess native PHP FFI might bring better performance. Am I wrong or not?

Hywan commented 4 years ago

WebAssembly has WASI (System Interfaces), which is “similar” to FFI (in terms of goals, it has many differences though, check https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/ to learn more).

I'm not sure PHP FFI will bring better performance. I'm curious! I'm going to update the extension to Wasmer 0.10 so that we will have WASI support