4

How can I override configuration files found under ./vendor/.../module_name/config/module.config.php?

And no, this link isn't working for me. I'm not sure why.

Tool
  • 12,126
  • 15
  • 70
  • 120

1 Answers1

8

Try naming the configuration file filename.global.php or filename.local.php.

Inside application.config.php it has this line:

config/autoload/{,*.}{global,local}.php

With regards to ZfcUser module and changing the main route.

In zfcuser.global.php modify the following at the bottom of the file:

return array(
    'zfcuser' => $settings,
    'service_manager' => array(
        'aliases' => array(
            'zfcuser_zend_db_adapter' => (isset($settings['zend_db_adapter'])) ? $settings['zend_db_adapter']: 'Zend\Db\Adapter\Adapter',
        ),
    ),
    'router' => array(
        'routes' => array(
            'zfcuser' => array(
                'options' => array(
                    'route' => '/member',
                    'defaults' => array(
                        'controller' => 'zfcuser',
                        'action' => 'index',
                    ),
                ),
            )
        )
    )
);
DrBeza
  • 2,241
  • 1
  • 16
  • 18
  • What do you mean with "module making the modifications"? None of my modules is overriding the configuration - I just want to change a route in the changing module's config. – Tool Sep 27 '12 at 12:41
  • I've adjusted my answer after looking at the link you supplied. It would appear the filename used in that article is not being picked up by the configuration loader. – DrBeza Sep 27 '12 at 12:43
  • I already have a file named zfcuser.global.php in ./config/autoload. Maybe there I should edit the configuration? (I've changed some parts of the module before) – Tool Sep 27 '12 at 12:47
  • I would personally create a new file containing the DI route changes but whilst solving the problem you could just modify the existing file and also it probably is worth outputting the merged configuration to see what changes are being applied. This can usually be done from a modules bootstrap function – of course in later versions of ZF2 you can just obtain it from the ServiceManager. – DrBeza Sep 27 '12 at 12:58
  • Perhaps you know the ZfcUser module? Could you show (in code) how would you change /user/login to /member/login route? I'll accept your answer, but if you could write up a more concrete guide of what I have to do to get from user/login to member/login, that would be nice :). – Tool Sep 27 '12 at 13:07
  • 2
    Either edit the zfcUser module.config.php or in your module overwrite the specific array entries. This is basic PHP. Check for "/user" and replace it by "/member" pretty standard ;) – Sam Sep 27 '12 at 15:16