2012-08-07 109 views
0

林非常巢到ZF2,並不能弄清楚如何設置全局路由器。 我知道如何在模塊級設置:Zend的2路由器設置

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將是一個合乎邏輯的地方。它在某個地方有記錄嗎?

回答

0

你的ZF2模塊定義getConfig()被合併與所有其他模塊CONFIGS並最終被加載AFER它模塊替代,如果一些配置鍵衝突。因此,您的getConfig()已經影響整個應用程序,其範圍不僅限於您的模塊。