简体   繁体   中英

Adding multiple modules in znd framework zf2

I am using the zf2 for developing my web application

I have multiple modules to be used in it. But when I initiate all my module in application.config.php files it will overwrite the services of 1st module with second one.

For example

In my application.config

'modules' => array(
    'Application',
    'ZfcAdmin',
),

The services of Application module is over written by the ZfcAdmin Module

I am already using different namespaces for both modules

Thanks Sam

This is a feature. It's assumed that if you provide the same service from two modules that they both fulfil the same role.

This concept is one of the core strengths of ZF2. Want to over-write something built into Zend? Or a component in a 3rd party module? Give your service the same name as the one you're overwriting and you can.

To solve your problem rename Countrytablegateway in ZfcAdmin to ZfcAdminCountrytablegateway or don't give your service short (non-namespaced) names or aliases. eg

'service_manager' => array(
    'invokables' => array(
        'ZfcAdminCountrytablegateway' => 'ZfcAdmin\Gateway\Countrytablegateway',
    )
)

or

'service_manager' => array(
    'invokables' => array(
        'ZfcAdmin\Gateway\Countrytablegateway' => 'ZfcAdmin\Gateway\Countrytablegateway',
    )
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM