SitePoint Sponsor

User Tag List

Results 1 to 25 of 397

Threaded View

  1. #13
    SitePoint Zealot Overunner's Avatar
    Join Date
    Mar 2004
    0 Post(s)
    0 Thread(s)
    Quote Originally Posted by 33degrees
    My inclination would be to use a Config class, with implementations for different file formats/database access etc., and either passing that to the mapper, or having it return an array which is then passed to the mapper. In the case of XML files, The Config object could be serialized to avoid having to parse the file each time it's used.
    How about the Config class reads a config file and creates a bunch of definitions.
    PHP Code:
    foreach($config as $name => $value)
    Then we don't have to worry about passing the config object around since the defined constants are accessible everywhere. But having global constants would perhaps break the layering?
    Quote Originally Posted by arborint
    Please contribute an XML or INI Reader if you have one and we can use it as a start.
    I've put together an extremely simple INI-parser. Intended use:
    PHP Code:
    $config = new Config(new IniFileReader('config.ini'));

    // ------------------
    class Config
    $configs = array();

    $configs $reader->parse();

    Things left to be done:
    * Check if the filename given to the reader actually is a .ini-file
    * Check if the file actually exists
    * ... probably some other checks...
    Attached Files Attached Files


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts