Extending PHP

Today, an article was posted on Zend’s Developer zone that caught my eye: Using YAML with PHP and PECL. Although the article itself is specific to an extension for parsing and emitting YAML, I found it interesting because it makes a great example of PHP’s flexibility as a platform.

PHP does not support YAML natively. If a developer wishes to implement YAML for a database migration or for any other reason, they must look to a third party library or roll their own. Several elegant solutions currently exist for YAML consumption, but they are written in PHP and must be interpreted with all other PHP code at runtime. This works almost always without a problem, but when efficiency and speed are of concern, a developer may want to consider a more low-level approach. The article demonstrates this well with the syck PECL package (ext/syck). This provides compiled binding with the Syck library. Since ext/syck is compiled, it is already optimized for the system. When the extension is loaded into PHP, the syck_* functions become directly available to the developer without having to include any third party libraries.

PHP itself is an open source language. As a result, any developer can write code to add additional functionality to the language, or to change the language at it’s core. As a convenience to all the PHP hackers around the world, the PECL project was formed. The project homepage (http://pecl.php.net/) lists many other packages which provide an incredible amount of additional functionality to the core of PHP.

Most of the time, PHP developers are satisfied once they get PHP configured on their web server (if it didn’t come that way already). However, with almost no effort, an entire world of lightning fast functionality can be added to your application. Furthermore, this functionality is modular — it can be turned on and off as necessary by simply editing the php.ini file.

Currently there have been no talks given at our group about extending PHP with PECL libraries. I think it would be great to have someone with some experience give a presentation on the subject. Our next meeting will be held on October 27th. Any takers?

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>