Hi,
I've adopted ZF as the framework that I am rewriting my modules. One of the
things I'd like to do is have a better way of changing / defining some of my
modules' behaviour.
I am considering using Zend_Config (not sure if .ini o .xml) and have
development, stagging and production config files. When the bootstrap is
called I find out which enviroment I am using and in my __construct I load
the appropriate config file.
Basically I have 3 questions:
a) should I use Zend_Config or is there any better way?
b) which format should I use? ini or xml? The parameters can be numbers,
strings or mixed arrays
c) If I use Zend_Config I am planning something like the snippet below. Any
advice on using it or a smarter way?
.../blog/application/<models,views,controllers>
.../blog/application/config/devel.xml, stagging.xml production.xml
index.php
...
if(some tests do define the environment as devel)
Zend_Registry::set('ENVIRONMENT','devel')
elseif(some tests do define the environment as stagging)
Zend_Registry::set('ENVIRONMENT','staggingl')
else
Zend_Registry::set('ENVIRONMENT','production')
blog/IndexController.php
class Blog_IndexController
{
function indexAction()
{
... throw an Exception if the environment is not defined...
$blog = new Blog(...,Zend_Registry::get('ENVIRONMENT');
}
}
Blog.php
class Blog
{
function __construct(...,$environment)
{
$config = new
Zend_Config(/path_to_module/config/".$environment.".xml") ;
}
}
Thanks.