PHP's Embed Server API (SAPI) In Rust

2 years ago
198

Just a short example of using using PHP's "embed" SAPI in a Rust program, instead of a C program.

There was a few tricks to get this to work, and this example is not complete. But it's a start.

The first thing to do was to get the PHP source code. I had to build the source using the --enable-embed option, which builds the Server API php_embed, which is a C library.

I then used bindgen to generate Rust bindings from the C header files for the libphp.so shared object file.

Once I had bindgen generate the rust bindings, instead of including this Rust library in my project, I just copied out the bindings file to my project. This means that my project needs to link to the libphp.so library.

Oh, and I said I would show you where I put the "bindings.rs" file; I created a "php" mod, and dumped it in there.

For IT, Software, & Data Privacy Consulting, please visit:

https://superserverhero.com

Loading comments...