getID3 retrofitted with namespacing and autoloading
Posted: Fri May 30, 2014 5:59 pm
While recently upgrading a client's commercial music web site from PHP 5.2 to 5.4, I took the opportunity to simplify class loading, and improve class and function naming security, by using namespaces and the autoloading features in the SPL introduced in 5.3. By structuring the class directory sub-structure to mimic the namespaces, it is possible to simplify the code that deals with class loading quite considerably. While the SPL manual contains a few simple examples on autoloading (http://www.php.net/manual/en/language.oop5.autoload.php), a better reference is http://www.dreamincode.net/forums/topic ... toloading/.
For the XSPF flash player I'm using to play snippets of my client's music for visitors to her site, getID3 is used extensively to extract the ID3v2 tags embedded in the mp3 and mp4 files. As I was introducing the namespace and autoload features into my own code, I observed that the existing software design and directory structures in getID3 make it an ideal candidate to be retrofitted. I decided to see how difficult it would be to to add namespaces and autoloading to getID3. (The site is still using 1.9.3, although that will be upgraded to 1.9.8 shortly.) There was certainly some hunting and pecking that went on, mostly in getid3.php, but after a few days I had a working version. Of greatest surprise was how simple the upgrade is - just a very few lines of code. Once I migrate these upgrades to 1.9.8, I am happy to make them available to James and his community here if there is any interest. Please let me know. Comments and suggestions welcome.
For the XSPF flash player I'm using to play snippets of my client's music for visitors to her site, getID3 is used extensively to extract the ID3v2 tags embedded in the mp3 and mp4 files. As I was introducing the namespace and autoload features into my own code, I observed that the existing software design and directory structures in getID3 make it an ideal candidate to be retrofitted. I decided to see how difficult it would be to to add namespaces and autoloading to getID3. (The site is still using 1.9.3, although that will be upgraded to 1.9.8 shortly.) There was certainly some hunting and pecking that went on, mostly in getid3.php, but after a few days I had a working version. Of greatest surprise was how simple the upgrade is - just a very few lines of code. Once I migrate these upgrades to 1.9.8, I am happy to make them available to James and his community here if there is any interest. Please let me know. Comments and suggestions welcome.