PHP extension template in Rust (ext_skel)

To whom it may concern, sharing port to Rust of what PHP ext_skel generated in C

Shows how to

  • export Rust function to C
  • declare Rust struct with nested unions for C (FFI)
  • have global C struct _zend_module_entry in Rust and pass pointer to C
  • uses cdylib and prefer-dynamic (and link-arg=-undefined link-arg=dynamic_lookup on OSX)
  • call Zend API from Rust shared library
  • port C Zend macro to Rust (e.g. RETURN_STR and PHP_FE_END)

I'm looking for reviews and feedback :slight_smile:

6 Likes

Fascinating!

I have so far avoided PHP in my career; Do I understand correctly that your template shows how to program Rust modules, that can then be called from PHP? Impressive!

That is a massively interesting strategy to get PHP-coders interested in more robust programming languages!
You are providing the ":syringe: gateway drug to safety" for them. :smiley:


P.S. I had to look up "THIMC" ("To whom it may concern"); acronyms aren't always clear, especially for non-native speakers, or across culture boundaries