我正在开发一个包含Web和Cms两个模块的项目。我想在子域中使用这些模块。
mydomain.com
- >网络模块
cms.mydomain.com
- > Cms模块
我在每个模块中使用了下面的module.config.php文件
网络模块 - > module.config.php
<?php
return array(
'controllers' => array(
'invokables' => array(
'Web\Controller\Index' => 'Web\Controller\IndexController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'mydomain.com',
'defaults' => array(
'__NAMESPACE__' => 'Web\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Index',
'action' => 'index',
),
),
),
),
),
),
),
'view_manager' => array(
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/default.phtml',
),
'template_path_stack' => array(
'web' => __DIR__ . '/../view',
),
),
'session' => array(
'remember_me_seconds' => 2419200,
'use_cookies' => true,
'cookie_httponly' => true,
),
);
?>
CMS模块 - &gt; module.config.php
<?php
return array(
'controllers' => array(
'invokables' => array(
'Cms\Controller\Index' => 'Cms\Controller\IndexController',
'Cms\Controller\User' => 'Cms\Controller\UserController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'cms' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'cms.mydomain.dev',
'defaults' => array(
'__NAMESPACE__' => 'Cms\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Index',
'action' => 'index',
),
),
),
),
),
),
),
'view_manager' => array(
'template_map' => array(
'layout/default' => __DIR__ . '/../view/layout/default.phtml',
'layout/system' => __DIR__ . '/../view/layout/system_layout.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
'cms' => __DIR__ . '/../view/script',
),
),
'session' => array(
'remember_me_seconds' => 2419200,
'use_cookies' => true,
'cookie_httponly' => true,
),
);
?>
这不能按预期工作。 Web模块mydomain.com
显示它的布局,但查看内容未加载。当我尝试cms.mydomain.com
时,CMS还会显示网络模块。你能指导一下问题所在。
答案 0 :(得分:0)
路由器配置对我来说没问题。您可能只有域名中的拼写错误。在web模块中,它是mydomain.com,而在cms模块中,你有一些mydomain.dev。
未显示的Web模块视图内容可能是由与路由无关的其他原因引起的。