【问题标题】:Zend 2 router settingZend 2 路由器设置
【发布时间】:2012-08-08 06:16:49
【问题描述】:

我对ZF2非常陌生,不知道如何设置全局路由器。 我知道如何在模块级别设置:

http://packages.zendframework.com/docs/latest/manual/en/user-guide/routing-and-controllers.html 说:

将 URL 映射到特定操作是使用以下路由完成的: 在模块的 module.config.php 文件中定义。我们将添加一条路线 对于我们的专辑操作。这是更新后的配置文件 代码注释。

// The following section is new and should be added to your file
'router' => array(
    'routes' => array(
        'album' => array(
            'type'    => 'segment',
            'options' => array(
                'route'    => '/album[/:action][/:id]',
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'id'     => '[0-9]+',
                ),
                'defaults' => array(
                    'controller' => 'Album\Controller\Album',
                    'action'     => 'index',
                ),
            ),
        ),
    ),
),

有没有办法为整个应用程序配置默认行为?或者我必须在每个模块中进行配置? config/application.config.php 将是一个合乎逻辑的地方。它在某处有记录吗?

【问题讨论】:

    标签: zend-framework routing


    【解决方案1】:

    您的 ZF2 模块在 getConfig() 中定义的内容与所有其他模块配置合并,如果某些配置键发生冲突,最终被加载的模块替换。因此,您的getConfig() 已经影响了整个应用程序,其范围不仅限于您的模块。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-09
      • 2014-05-02
      相关资源
      最近更新 更多