PHP, Zend Framework and Other Crazy Stuff
Archive for February 20, 2007
OpenID library for the Zend Framework?
Feb 20th
A few months ago I was requested to add OpenID support (a growing trend) to a small website. Some of the members of the society whose website this is, were running blogs and Flickr sites and thought it would be “neat”. Being a fan of “neat” myself, I figured it would be reasonable to add, and indeed it was. I was using the JanRain PHP-Openid library seeing as it is likely the only full implementation in PHP so far.
Here in the present, everyone I work with is all too aware of OpenID. It’s been growing up, especially with the current 1.2 set of proposals, and of course support for OpenID is bound to be spurred higher by recent support announcements by Mozilla for Firefox 3, and Microsoft for Windows Vista. Also, the open Yadis specification is useful outside of OpenID for other things.
Loving PHP5 and being a long time OOP fanboy, I’ve decided to take on a small personal project – writing a strictly PHP5 library to support Yadis and OpenID respectively. Partly to learn the teeny details surrounding OpenID/Yadis, and also to add a pure PHP5 library which is strictly object oriented. Of course such an undertaking is a complete pain in the ass since OpenID requires a lot of functionality from cryptographic algorithms (HMAC/Diffie Hellman), big integer math (bcmath/gmp/big_int support) to simple things like making HTTP requests from PHP.
Enter the Zend Framework. The ZF has become central to no few of my projects. I also use other frameworks, but I just find the ZF hits the sweet spot a lot. Since the Zend Framework has a lot of independent components, relying on it lets me take advantage of components like Zend_Service_Abstract, Zend_Uri and Zend_Http_Client among others. If you’ve ever looked under the hood of the JanRain PHP-Openid library you’ll notice they implement *all* of this without a single dependency on PEAR or other external classes. I don’t want to repeat that practice here.
I guess I can be accused of “Not Invented Here” syndrome. I’m willing to plead guilty on that. In my defence, there exists only the one (AFAIK) php library dedicated to OpenID. It’s written in PHP4 and mixes procedural functions into it’s otherwise OOP approach. I found it unnecessarily complex and duplicative – a lot of its functionality is readily available from PEAR or other sources. But outside my personal impressions, I love tinkering with and learning the nitty-gritty of new ideas. I do hope the library will prove acceptable enough to eventually be added to the Zend Framework. Regardless of that suggestion I intend plundering the ZF for all its worth, and release everything under the New BSD license anyway.
In the meantime, as a bit of a brain dump exercise I’ll be posting a lot more about the technologies underlying OpenID. It’s a well documented area, but I doubt everyone reading this blog has the time to read through all the associated specifications and their recent proposal updates. Should be a fun journey – for me anyway
.
