Being relatively new to Zend Framework, I’ve been exploring it’s intricacies for about 7 months now, I’ll be the first to admit that I didn’t fully understand some of the power that comes along with the tool. It’s like when you get your first car and all you want to do is drag main with it. Sure, it’s fun, you feel cool, and the chicks dig it. However, you’re not getting the most out of what you’ve got. Later in life you discover that you can do other cool stuff with cars like roadtrips, adding your own stereo and spending all Saturday giving it a fresh coat of wax. I digress … the point being that Zend is cool and I’m about to give you an example of why.
I’m overhauling a site that was built in Zend Framework. Being built in Zend Framework isn’t the reason it needs overhauled, poor architecture is the reason it needs overhauled. However, I discovered in my journey that I was going to have to migrate some data from a poorly constructed .ini file over to a fully functioning MySQL database. I wrote the script the same way I write many data manipulation scripts, to run from the command line. I spent my 2 hours, checked and double checked that everything was right, and then gave it a run to see how it worked. I was immediately reminded that Zend_Config_Ini will not function from the command line unless you also have Zend Platform configured and running on your local machine. Booooooooooooooo
I took a quick look at the documentation on Zend_Config_Ini and realized that it was really just a glorified wrapper for the native PHP function parse_ini_file(). Great I thought! The kicker is (wait for it) that Zend_Config_Ini has some AWESOME built in functionality built in that let’s you not only navigate down a config file, but you can also find out what a node is inherited from. In other words, there is a quick mechanism to determine where the node came from. Since I didn’t have access to this functionality, I was forced to write it myself. Not complicated, but it did take a couple minutes and it definitely made me appreciate the nice built in functionality that came built in. What can I say, they don’t make em’ like they used to …. they make em’ a whole lot easier to use.
Looking for more information?
- Check out the manual on the Zend_Config_Ini function:
- Check out the PHP manual on parse_ini():