problem with zend module specific configuration

前端 未结 3 901
情话喂你
情话喂你 2021-02-20 03:10

iam using zend framework to build a REST web service and i am using modules to separate my api versions.

Now, i want to have a separate configuration file for each of my

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-20 03:25

    The solution (My_App) you refer to in your question does not require any additional configuration for module specific database connections, or any other module specific configuration (except for routes). All you need to do is to declare a MultiDb resource in the application.ini as db1. Then you can declare any module specific database resource in the requested module's respective module.ini as db2, db3, db4... etc... you do not need any additional configuration. I placed an example in the download file at my github. Not to disrespect the response by "mingos" above but there's no need for any additional code in My_App.

    Here's the exact verbage taken from the download (application.ini):

    ...if this resource is declared here, then it
    will be available to all modules. If different
    db resources need to be used for different
    modules then MultiDB resource can be
    initiated. Example: A general db resource can be
    defined here and a module specific db can be
    declared in its corresponding module.ini.
    The db resource declared in the module will not
    be available to other modules but the db resource
    in this application.ini will be available to all
    modules...
    

    Then it declares a single db resource as an example in the download. Just change it to a multi db resource. Declare the application wide needed db resource in application.ini, and any additional db resource that is needed for any specific module in their respective module.ini files. It's straightforward. That's all you need to do. Once you understand the logic behind My_App, you will see it's very powerful.

提交回复
热议问题