So I didn’t post to my blog for more than a month, but I suppose I had a pretty good reason: This past month at Rhizome, we launched our newly redesigned site. This was a massive project: Rhizome is the most complicated website I have ever worked on, and by my account, my intern Jason and I had to update more than 150 PHP files by hand.
Patrick helped me immensely by giving me tips on clever PHP hackery. You can use ob_start and register_shutdown_function to post-process a page’s output, and wrap the page’s unique content in standardized nav junk. When this is combined with
php_value auto_prepend_file in your Apache configuration to automatically prepend your includes, you can drastically reduce the amount of cut-and-paste required in PHP.
PHP’s community is curious: When you first come to the language, it seems as if it were designed to cause spaghetti code, since so much of the documentation focuses on low-level hacks with no interest in design principles. But the PHP language community is a big tent, and on closer inspection there are people laboring away to make elegant components with an inelegant language. Unfortunately, they’re not easy to see for all the newbie sites, and you might spend years coding PHP without ever seeing them. As Ruby grows, PHP is an example worth studying, and in some ways, worth trying not to emulate.