15 Excellent Resources for PHP Extension Development

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.

Online Articles or Websites:

Printed Books:

Information on Documenting PHP and PECL Extensions:

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.

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.

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.

The PHP ssdeep Extension is Now in PECL

External Link: The PHP ssdeep Extension is Now in PECL

This means you can now install it easily by simply running:

sudo pecl install ssdeep 

There is also proper documentation in the PHP manual which can be found at php.net/ssdeep.

For more information on the extension either see the PECL project page or the ssdeep PHP/PECL extension’s homepage.

php_ssdeep Fuzzy Hashing PHP Extension

External Link: php_ssdeep Fuzzy Hashing PHP Extension

Updated 16/9: php_ssdeep is now in PECL so I have updated this post to reflect that.

On a recent project I needed a fast way to compare documents for likeness and return a percentage match. With much research and one unanswered Stackoverflow post later I came across Jesse Kornblum’s ssdeep utility intended for computer forensics such as looking for signatures in files when hunting rootkits etc. All the technical details of fuzzy hashing are described in his 2006 journal article Identifying almost identical files using context triggered piecewise hashing.

I was using a wrapper around the ssdeep binary written in pure PHP, but I recently decided to write my first PHP extension by tying into the fuzzy hashing API ssdeep provides. The result is now a PECL extension or module and the BSD licensed source code is hosted on PHP.net’s SVN.

There are full instructions provided in the PHP manual and the php_ssdeep site to install the exension and use the provided functions. If you end up using this extension or its code I would be very interested to find out more about your project.