Zend 2: How to override module's configuration

2019-06-26 16:31发布

问题:

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.

回答1:

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',
                    ),
                ),
            )
        )
    )
);