I think such a proposal would be great, of course I would like to see it taken one step further, since I'm big on making it easy to quickly build applications with minimal work...

If there was a normalized way to register the "default" configuration. So instead of the "amateur" developer having to do:
   Zend_Db::factory($config->db->toArray())
or
   Zend_Db::factory($config->db)

If the did:
   $conf = new Zend_Config_Ini($filename, 'production');
   Zend_Registry::setDefaultConfig($conf);
They could do:
   Zend_Db::factory()
Which would consult the default registered configuration and instantiate the default database, based on a standardized schema.

I only say this since I've recently found myself creating Zend_View objects in the middle of nowhere and needing to insure that all of the default properties are available.

--koblas

Simon Mundy wrote:
Hi All

One of the strategies I'd like to see ZF heading toward is the ability to pass single Zend_Config container to components in the bootstrap to set up an application.

Currently many of the components all a $config->toArray() or similar to achieve this, but I think it would be excellent to allow a more seamless approach with components recognising a Zend_Config instance and then pulling out the specific values. It would create a much more organised, lean bootstrap and create better consistency when utilising ZF components.

For this work, I'd see the following steps needed:-

* Review the existing 'defaults' proposal by Gavin that partially addresses this issue (by allowing each component 'defaults') * Compile a list of components that use configs and review their usage (E.g. Routes, Mail, Db, Cache... etc.)
* Some interest by the community for this to happen! :)
* Draw up a proposal (I'll put up my hand on this)
* Review documentation and look at a consistent way of documenting component config defaults/attributes

I don't think we would need to pass the _whole_ config to each component, as this may interfere with developers' naming schemes - it would be a matter of identifying individual sections within a config and passing them over:-

E.g.

$db = Zend_Db::factory($config->db);
$cache = Zend_Cache::factory($config->cache);
$mail = new Zend_Mail($config->myMailSection);

However the 'keys' or 'attributes' within each module would, of course, need to adhere to a strict naming scheme. Most components already document this in some form or other, but I thought perhaps each component's documentation could include a table of attributes at the start of their respective sections to make tracking this down somewhat easier (as well as an appendix somewhere on the ZF docs).

Any thoughts? It would be nice to fast-track a proposal to see how quickly it could be tackled. A slim chance for 1.1 or maybe 1.2?


--

Simon Mundy | Director | PEPTOLAB

""" " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "
202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000
Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124
http://www.peptolab.com <http://www.peptolab.com/>

Reply via email to