Whilst developing a PHP extension recently I spent quite a bit of time researching exactly how to create an extension, the best practices and the DocBook format of the PHP manual for documenting the extension.
By the time I finished writing the extension I had found some very good resources both on the web and in print.
Printed books:
- Sara Golemon’s Extending and Embedding PHP
- Advanced PHP Programming by George Schlossnagle
- Building Custom PHP Extensions by Blake Schwendiman
Online articles and presentations:
- The Internals section of the PHP manual
- Kristina Chodorow’s PHP Extensions Made Eldrich on her blog in 2011:
- Sara Golemon’s Zend DevZone articles with parts I, II and III (2005, 2006):
- Wez Furlong’s Extending PHP slides
- Marcus Börger and Johannes Schlüter: PHP Extension Writing slides
- O’Reilly Programming PHP Chapter 14: Extending PHP
- Paul Osman’s Wrapping C++ Classes in a PHP Extension article on Zend DevZone
Documenting PHP and PECL extensions:
- PHP Wiki: Documentation Introduction
- PHP Wiki: Editing Documentation
- PHP Documentation Team: How to pages
- PHP Wiki: Documenting PECL Extensions
Pyrus
Also worth a mention is the ability of the new PEAR2 Pyrus installer to generate a skeleton for you to build your PECL extension upon - see the generate-ext section of the manual.
Pyrus can also be used to package your extension up for release using the pickle command.
Support
For more help there is a PECL mailing list and IRC channel (#php.pecl on efnet), both of which are in the support section of the PECL website.
Build tools
Whilst not strictly for PHP extensions the Autotools: a practitioner’s guide to Autoconf, Automake and Libtool book by John Calcote on the Free Software Magazine is very useful reading for an understanding of the build process involved in extension writing.
There is also the GNU Manual for Autoconf and GNU Autoconf, Automake, and Libtool by Gary V. Vaughan et al.
note
This article has been updated a number of times as it is reasonably popular and new resources have become available since it was written.
Since writing this article a new Wiki article has been added on php.net with a list of resources. Some of which I have not already covered here.