Using the blog post I tried the same for PHP extensions:
https://gist.github.com/beberlei/3c89c86d3a9f96e4c9f2
It compiles and works for php -m and php --info, but calling the function segfaults sadly. Wondering if it is just a small fix necessary to get going.