The PHP module runtime could provide the C functions that would call back into the PHP code written by the user, the same way it's implemented in [DBD::SQlite], for example. [DBD::SQLite]: https://metacpan.org/pod/DBD::SQLite#$dbh-%3Esqlite_create_function(-$name,-$argc,-$code_ref,-$flags-)