views:

204

answers:

3

I want to store my database connection information in a single file, which both PHP and Ruby scripts can use.

Should I use name-value pairs, yaml, xml, or something else?

A: 

YAML, XML, JSON, a proper database — any common format will have support on both sides.

Chuck
You're suggesting I put my database configuration in 'a proper database'? Where then would I store the configuration information to connect to that database?
brianegge
Well, you have to hardcode the info to get to the config no matter what format you use — SQLite wouldn't be much more of a stretch in that respect than XML. But I wasn't actually suggesting that option in particular — I just threw it in at the end to emphasize the "any common data storage format work."
Chuck
To whoever downvoted: Feel free to point out the factual inaccuracy in your post. Because it's not there.
Chuck
Agreed that SQLite would be a common format readable by both. I quite like SQLite, but would associate the term 'proper database' with an external database server.
brianegge
+4  A: 

YAML is probably a good option - it is very simple to implement, yet it can take you a long way with flexibility.

BTW. Sounds as if you may have some similar problems that are discussed on railsforphp.com Here is the article on PHP and YAML:

http://railsforphp.com/2008/01/08/php-meet-yaml/

leonm
+1  A: 

I'd suggest JSON. It can be read natively by PHP with json_decode(). Surly Ruby must have some facilities to read JSON. Plus you can read it directly from JavaScript.

Kamil Szot
Thanks. It looks like it would be slightly easier to get Ruby to read JSON that to get PHP to read YAML. Both require an extension, but I'm more familiar with installing ruby gems.
brianegge