Programming with Configuration Files

308 days ago
tags: , , ,

Recently I was working on developing an application that required a configuration file to setup. I considered several options for the file, keep it in the native language (PHP), make it plain-text or use XML. I didn’t like any of the options because the configuration has to be approved by certain stakeholders of the data at various stages throughout the life of the application.

XML is too hard to read for management-types. Plain text wasn’t all that easy to handle from a code perspective. I could have used a native language configuration file that read more like plain text (mostly comments, few directives, etc), but still was not liking it.

Then I remembered that when I played with Ruby on Rails it used something called YAML, and thought I’d give that go. It didn’t take too long at all to get the hang of writing the syntax for YAML. I then needed to find a way to process it with PHP. I found a few.

I started with the top entry on a Google search for PHP YAML. I found spyc, which is a very simple YAML class for PHP. I also found Syck, which is apparently more widely used and ported to several languages (although Ruby looks to be the primary focus). But I decided to download spyc, which appeared to geared toward PHP, gave it a whirl and instantly had what I needed. I liked it so much, I packaged it up for Fedora. I should probably also mention that I looked at JSON, but found YAML to be more complete and easier to read for what I needed to do. JSON is cool though in that it is a subset of YAML for the most part and works nicely with Python.



Using the Google API from PEAR

685 days ago
tags: , , , ,
The Services_Google package is simply a wrapper around the SOAP extension and is used to access the Google Web APIs (http://www.google.com/apis/reference.html) for the search engine, spelling suggestions, and cache. To access any of these services, you must obtain a license key by registering for an account. A link to the registration page is available from the previously mentioned URL. Because this package is a wrapper for SOAP, both PHP 5 and the SOAP extension are prerequisites for installing and using this package.
Click here to read more