Re: Can someone please point me to a valid example of how to use the Config pkg?
| From: | Evan Broder | Date: | Wed, 25 Aug 2004 22:55:01 +0000 |
| Subject: | Re: Can someone please point me to a valid example of how to use the Config pkg? | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14306@lists.php.net to get a copy of this message | ||
That was actually a config file that Config.php generated. It was quite simple - a configuration form returned the data as an array of section=>directive=>value. I could then parse that as a PHP array and write it out to a file.
I can try to dig up the code if you really want to see...
Of course, chances are I'm not using the library properly to begin with, but that's not important.
Evan
Matte Edens wrote:
I've been using Config but only for reading values. I haven't been editing them. That being said, I'm using it with the array structure. I just named my config array "conf" and it worked. Sample array is here... $conf = array( 'toolkitdir' => 'd:/projects/toolkit/php/', 'mysql' => array('user' => 'foo', 'password' => 'bar', 'host' => 'localhost', 'database' => 'db') ); I've never created the array the way that Evan did. Separate lines. matte - matte@arubanetworks.com webmonkey / arubanetworks.com / airheads04.com / wi-fi-it.com Kushmit Indurain wrote:Thanks Evan for the info :) But that seems incredible... so Config can handle Windows-style INI files (which have been pretty much deprecated in favor of the registry), and XML files (used only sparingly in the real world for config data). But the most common format for PHP config files can't be handled by Config?!!?! Amazing. Oh well. I guess I will have to start putting something together using parse_ini_file. Thanks again, -K --- Evan Broder <ebroder@ebroder.net> wrote:The type of config file you described will not work with Config because the config entries need to be part of an array. aka $settings["var1"] = "blah"; $settings["var2"] = "blahblah"; etc... Evan Broder