Muschamp Rd

Damn PHP Coders

October 13th, 2010
PHP logo

As someone who has written and given away way too much PHP code, there are definitely bigger priorities than ensuring your open source PHP code works perfectly, forever. People have lives offline. They have commitments. There is a need to make a living so although I’m still not the biggest PHP fan if I have time I plan to update my mashup codebase but my number one priority as always is finding a well paying job.

API Documentation Disappoints

The Amazon Product API let me down or at least these instructions, I couldn’t find anything better in the real Amazon API documentation so  I left a question on their forum.

iTunes API

With no answers forthcoming from Amazon I had to look around for alternate ways to get tracks and audio previews. iTunes Music Store should have this information, but they don’t take Canadian affiliates so I wouldn’t get any money if anyone bought anything. That wasn’t even on the radar when I decided to build my CD Cover Gallery, but after putting in so much time and effort into the code and deciphering various APIs and their responses. I tried to make my code as versatile as possible and reuse-able too. Alas the more I work on it the more shortcomings and missing features I find in various PHP implementations of APIs.

MusicBrainz API

I tried MusicBrainz. I’d read that it was a good source of free music information. Their API documentation isn’t the best. But as I was writing my own methods, I learned of phpBrainz. So I decided to switch my efforts to using Scott’s code but it wouldn’t even run right out of the source control system. In fact the link from doesn’t go to the source control system that comes up number one in Google for phpBrainz.

Rolling My Own

I ended up implementing some methods for the API that I didn’t know were missing from Matt’s PHP. I also discovered that the getInfo method in album.php doesn’t copy the track information from the XML to the array Matt insists on returning for abstraction purposes. So I think I’ll be implementing that next. However the more I work on this “small” project the more I find I need to fix and modify other people’s code so it works like I think it should. This means anyone looking to use my code would need all the modifications and additions I’ve made to other PHP codebases in order to get my stuff to work.


Most of the work for my albumCollection.php class is done by two methods, one in the API to get information about an artist and another in the Amazon Product API to get information about an album. Now I can get information from MusicBrainz and I plan to get more information from, iTunes Music Store, and possibly Amazon if someone tells me what attribute is mandatory that isn’t listed as mandatory in the documentation.

Testing and Documentation are Important

I don’t think people in PHP land test their code enough before they throw it online and tell people to download it and use it. I’m not sure a full suite of unit tests needs to be written for every class and method, but when your codebase is linked from an official website and you repeatedly say it is the best and easiest way to do something in PHP, perhaps you should make sure when you download it from the source control system, it actually will run the example code included.

How much of an obligation do people have to ensure their code works when they create a semi-official implementation of an API for a Web Service and then encourage people to use?


  • matto1990 says:

    To be honest, the code I wrote is 3-4 years old and was release when I was first learning about OO programming (you can tell if you look at the quality of the code). I have flirted with the idea of taking all the code down, however I thought it would still be useful for other people to base their work off. As the licence say (you did read it right) it is provided without warranty. I make no claims that it works. It worked perfectly when it was written all those years ago, but as you’ve found out, things have changed.As it’s open source you’re free to take the code and fork it into your own project if you feel like it. I’ve kept it up purely so people can do that and so all those hours I spent using it as a learning aid are not wasted.

    Edit: Oh I forgot to mention. I was 15 or 16 when a lot of that code was written and had never been taught any programming

    • Muskie says:

      Hmm… No worries. Isn’t really you I was aiming at here. More of a general rant, however I do wonder in the era of Google and especially when an API links directly to code, is the author of that code authorized to maintain it and for how long.

      I guess it is all about pride. I did look at the licenses, this is just a hobby project, a little bolt on to my website that has grown out of proportion to the original idea.


      • matto1990 says:

        That’s fair enough. I think Google makes it easy to find code so that you don’t have to write it yourself, but there’s no knowing what quality the code is. It might have been fine at the time and then just fallen into disrepair

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Posts on Muskblog © Andrew "Muskie" McKay.
CFA Institute does not endorse, promote or warrant the accuracy or quality of Muskblog. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.