On Thu, Aug 16, 2012 at 12:01 PM, Ralf Eggert <
[hidden email]> wrote:
> Hi,
>
> I hope, no one is already sick of all my dump ZF2 questions in the last
> couple of days. Anyway, here is another one.
>
> I am trying to figure out the difference between the Module.php and the
> module.config.php. Well, I know that Module.php is a class and
> module.config.php is just a configuration array. It is rather the
> responsibilities I am wondering about.
>
> Which stuff is configured in the Module.php?
>
> And which stuff is configured in module.config.php?
>
> Can everything, I configure in module.config.php be also configured just
> in Module.php?
>
> Can everything, I configure in Module.php be also configured just in
> module.config.php (In this case the Module class only needs the
> getConfig() method)?
Exactly -- as long as you return an array or Traversable from
YouModule\Module::getConfig(), you're fine. The
config/module.config.php is just a suggestion. You can perform any
logic to load any config yo would like in a getConfig() method. For
example, you could use Zend\Config to load an ini instead of including
a php file/array if you wanted to. Zend Framework itself makes no
assumptions about what's is within a module besides Module.php.
To clarify:
class Module
{
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}
With config/module.config.php like this:
<?php
return array('foo' => 'bar');
?>
Is functionally identical to:
class Module
{
public function getConfig()
{
return array('foo' => 'bar');
}
}
or..
class Module
{
public function getConfig()
{
return new \Zend\Config\Config(array('foo' => 'bar'));
}
}
--
Evan Coury