Zend_Config support

0 views
Skip to first unread message

scramatte

unread,
Aug 21, 2009, 3:17:22 PM8/21/09
to concentre-daemon
I think that Zend_Config should not be included directly into
Zend_Daemon_Abstract. Instead we should add "options" parameters
something like this :

protected $_defaultOptions = array(
'key' => 'value',
);
protected $_options = array();

public function __construct(array $options=array())
{
$this->setOptions($options);
...
}

public function setOptions(array $options)
{
$diff = array_diff_key($options, $this->_defaultOptions);
if ($diff) {
list($key, $val) = each($diff);
require_once 'Concentre/Daemon/Exception.php';
throw new Concentre_Daemon_Exception(null, "Unknown
Concentre_Daemon option: $key");
}

foreach ($defaultOptions as $key => $val) {
if (!array_key_exists($key, $options)) {
$options[$key] = $val;
}
}

$this->_options = $options;

return $this;
}


Most of the ZF class use this (Zend_Db, Zend_Form , ...)

scramatte

unread,
Aug 21, 2009, 7:43:47 PM8/21/09
to concentre-daemon

We can be able to setup daemon via :
- command line parameter (-u , -g , ... )
and / or
- confif file like /etc/daemon/daemon.ini

Zend_Config init should occurs in the bootstrap file

Denis Baklikov

unread,
Aug 22, 2009, 6:33:39 AM8/22/09
to concentr...@googlegroups.com
Hi All,

I agree with Sébastien. Use Zend_Config is one the best practices in ZF. Almost every module can receive config as parameter.

Also, to simplify parameters passing in command line we can use Zend_Console_GetOpt
http://framework.zend.com/manual/en/zend.console.getopt.html

Regards,

Denis
--
Kind regards,
 Denis Baklikov
Reply all
Reply to author
Forward
0 new messages