简体   繁体   English

访问ZF2应用程序的基本配置

[英]Accessing the base config of ZF2 application

I have a base config of my ZF2 application, which is in the following structure of my ZF2 application: 我有一个ZF2应用程序的基本配置,它在我的ZF2应用程序的以下结构中:

/frontend
        /config 
              /autoload -> (here I have config.php file - which is base config)
              /brand -> (here I have config files for my vhosts)

When I need things from my vhosts config I simply do like this: 当我需要来自我的vhosts配置的东西时,我只需这样做:

$this->config()['SomethingGoesHere']

My question here is, when I'm located in my vhost (www.sitename1.com). 我的问题是,当我找到我的虚拟主机(www.sitename1.com)时。 I would like to access the base config within my vhost, how can I do that guys?? 我想在我的vhost中访问基本配置,我该怎么办?

If you want to set different configuration for different virtual-hosts I would not recommend to do it like this. 如果要为不同的虚拟主机设置不同的配置,我建议不要这样做。 You can set more advanced configuration differently, for example by using environmental variables. 您可以以不同方式设置更高级的配置,例如使用环境变量。 You can read more on this here in the documentation chapter: Advanced Configuration Tricks . 您可以在文档章节: 高级配置技巧中阅读更多相关内容。

The correct solution also totally depends on what variables you are setting and what you want to use them for and where you want to use them. 正确的解决方案还完全取决于您设置的变量以及您要使用它们的位置以及您希望使用它们的位置。 If you provide more details on what you are trying to do (what is in your "base config" ?) it would be possible to give a more suitable answer for your needs. 如果您提供有关您要执行的操作的更多详细信息( “基本配置”中的内容 ?),则可以根据您的需求提供更合适的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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