[PEPr] Comment on Configuration::Config_Lite
| From: | Christian Weiske | Date: | Fri, 31 Dec 2010 11:05:39 +0000 |
| Subject: | [PEPr] Comment on Configuration::Config_Lite | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-53928@lists.php.net to get a copy of this message | ||
Regarding exceptions: If there are any SPL exceptions, extend from them.
Implement/extend your own package exception class.
The ini file has a <?php exit; ?> in it. This is bad in two ways:
- php code in a .ini file
- "exit" stops the whole application. If you want to prevent inclusion of
the ini file in php, you should just use return; - but i'd completely
remove it.
Introduce a "Config/" folder that contains Lite.php in your git repo. This
makes unit testing easier.
You could use file_put_contents() instead of fopen&&fwrite&&fclose.
function get(): null is a good default value sometimes. Making "null" throw
an exception is not a good idea.
__toString() should now throw an exception when no filename is set - maybe
I am in the process of creating a new config file and want to debug it. In
that case, I get an exception.
The Config package supports directives (keys) like "foo[]=bar" or
"foo[bar]=baz", opening an array. Maybe Config_Lite should support that,
too.
Config also supports comments in ini files, which is a good thing. I'd like
to see that in Config_Lite, too.
Really nifty would be Config_Lite implementing ArrayObject - so that
reading/setting config values would be as easy as $config['section']['foo']
= 'bar'.
There should be a way to set key/value pairs without a section, i.e. by
using a null/empty section name.
How do you handle multi line values? Currently, one can break the ini file
by setting a value with newlines. Config does that with a configurable
line-continuing string, i.e. \ at the end of the line.
--
http://pear.php.net/pepr/pepr-proposal-show.php?id=645