我们可以在 Zend framework1.11 中为模块创建虚拟主机吗

could we create Virtual host for modules in Zend framework1.11

目前我有一个 zend 1.xx 项目,其中包含三个模块 module1module2module3

我的要求是为每个模块创建单独的虚拟主机。

如果我们输入 http://module1 应该加载 module1,然后我们输入 http://module2 那么它应该加载项目的 module2

对于非默认模块,虚拟主机中的 DocumentRoot 值应该是多少。

对于默认模块 .../project/public 工作正常,但对其他模块无效。

你绝对不能使用虚拟主机来做到这一点,除非你真的按模块拆分你的代码库(意味着只有模块 1、模块 2 或模块 3 的代码副本)。

您可以非常轻松地禁用 default routes (which will remove access to your app altogether I believe, I suppose you haven't defined your own routes), then create a Route chain that chains a route hostname 和看起来像默认路由的路由。

所以:

  1. 禁用默认路由
  2. 像没有模块的默认路由一样创建一个路由
  3. 创建 3 个路由主机名(每个域一个)
  4. 创建 3 个具有路由主机名 (3.) 和默认路由 (2.) 的链

我通过在 application.ini 文件中使用以下代码集实现了这一点 -

; This piece of code used for rounting usoc host to default module 
resources.router.routes.plain.type = "Zend_Controller_Router_Route"
resources.router.routes.plain.abstract = true
resources.router.routes.plain.route = "/:controller/:action"
resources.router.routes.plain.defaults.controller = "index"
resources.router.routes.plain.defaults.action = "index" 

以上代码用于默认模块。

; This piece of code used for rounting beat host to beat module
resources.router.routes.beat.type = "Zend_Controller_Router_Route_Hostname"
resources.router.routes.beat.route = "beat"
resources.router.routes.beat.defaults.module = "beat"
resources.router.routes.beat.chains.index.type = "Zend_Controller_Router_Route"
resources.router.routes.beat.chains.index.route = ":controller/:action/*"
resources.router.routes.beat.chains.index.defaults.controller = "index"
resources.router.routes.beat.chains.index.defaults.action = "index"

以上代码如果beat模块和主机名也是beat