首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Zend Framework 2模块到子域映射

Zend Framework 2模块到子域映射
EN

Stack Overflow用户
提问于 2016-08-06 07:04:52
回答 1查看 55关注 0票数 1

我正在做一个有两个模块的项目,如Web和Cms。我想使用这些模块的子域。

mydomain.com -> Web模块

cms.mydomain.com -> Cms模块

我在每个模块中使用了下面的module.config.php文件

网络模块-> module.config.php

代码语言:javascript
复制
<?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模块-> module.config.php

代码语言:javascript
复制
<?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也会显示web模块。你能带我去找问题所在吗?

EN

回答 1

Stack Overflow用户

发布于 2016-08-06 14:17:07

在我看来,路由器配置看起来没问题。您可能只是在域名中输入了一个错误。在web模块中,它是mydomain.com,而在cms模块中,则有一些mydomain.dev。

Web模块视图内容不显示可能是由于与路由无关的另一个原因造成的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38801530

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档