The fun of writing PHP Extensions
Lately i’ve been digging into writing PHP extension, for multiple reasons, first knowing the language from the inside can never hurt (and i would recommend for every PHP developer to take a look at the PHP internals, you’ll learn a lot), secondly, PHP being my primary language, i wanted to contribute, i’m not much of a QA person so writing test, no thanks, so i decided to take a look at writing PHP extension, and last, i’m a curious person by nature, i love getting my hands in everything that looks fun - which in programming resolve to pretty much everything - so why not take a look at the heart of the beast.
So i began to read some stuff, starting by notes i’ve taken at a previous Confoo talk on writing PHP Extension (by Marcus Boerger and Johannes Schluter), that got me started, but not too far, i then started lurking on the internet, only to realize two things :
- There is no useful documentation of the Zend Engine, PHP engine and such. All you will find is a handful of articles that will introduce you to the extension writing process. (They are useful, don’t get me wrong) After that you are on your own, reading the source code of PHP and other extensions to understand the mechanisms.
- Getting help is almost impossible, as comparison, i’ve been playing around with NodeJS for the past months, and just hanging on the IRC channel will get you farther than anything available for PHP.
The only bright light in this very dark sky, is this book: http://www.amazon.com/Extending-Embedding-PHP-Sara-Golemon/dp/067232704X , Extending and Embedding PHP by Sara Golemon. I’m still going through it, but i would recommend it to anybody who plans to write a PHP extension. It’s a very complete book, that will get you most of the information you’ll need.
But still, I was really disappointed by this lack of documentation and help, the PHP community is great, when you don’t try to dig too far. For the language and the community, PHP needs to better expose itself, it would help getting people interested, involved, and it would do some good to the language itself.
As i don’t want to look like the guy who’s bitching but not doing anything, starting 2011, i will try, on this blog, to document 1 function of the PHP Engine, Zend_Engine, per two days or so. That will only cover my limited knowledge of it all, but may be it will get the attention of more knowledgeable people in this matter.
On this note, happy holidays to all of you my 10 to 15 readers.