Press "Enter" to skip to content

Some Resources for PHP Extension Development

Lately I've had a feeling that more and more people are starting to work on PHP extension development (more and more people are coming to ask questions, haha)
First let me apologize here: sometimes some people's emails end up in the spam folder and I can't reply in time.
To make things easier for everyone, I'll list some resources you might find useful here.
1. First, I'd recommend a book, "Extending and Embedding PHP". If you have time, I suggest reading this book carefully before you start (there's no Chinese version currently).
2. Google/Baidu — no need to say more about that, right?
3. The PHP source code contains some well-written "examples", all under the ext/ directory. The vast majority of Zend_API usage has examples in there.
4. pecl-dev at lists.php.net — this mailing list is the exchange list for extension development. If you really can't find the answer to your question via Google/Baidu, you can email this list to ask. However, generally you'll need to be patient for a reply (most people have a 15-hour time difference with us; of course, if I see it, I'll try to reply).
5. efnet #php.pecl — PECL developers gather here, and you can come here to ask (I'm on it all day). However, you can only speak English here, and when asking, don't paste code directly — use a tool like pastebin instead (so still everyone is advised to email pecl-dev).
6. Whenever possible, write some phpt test cases (there are examples of how to write phpt under each standard extension, in the tests directory) to test your extension.
7. When testing, compile PHP with --enable-debug to test your extension. You need to make sure that running your extension's logic produces no error output at all.
8. Use valgrind to detect memory leaks.
Hope this is helpful to everyone.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.