2014-02-16 44 views
0

我是一個ZF2乞討。我嘗試做一個路由器,當我在視圖中使用。我有這個錯誤: 致命錯誤:未知的異常'Zend \ Mvc \ Router \ Exception \ RuntimeException'帶有消息'Route with name'文件「找不到'Zend Framework 2路由器

你能幫我嗎?

這是我的代碼:

<?php 
return array(
    'controllers' => array(
     'invokables' => array(
      'Documents\Controller\Documents' => 'Documents\Controller\DocumentsController', 

     ), 
    ), 
    'router' => array(
     'routes' => array(
      'documents' => array(
       'type' => 'segment', 
       'options' => array(
        'route' => '/DocumentsController[/:action]', 
        'constraints' => array(
         'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 

        ), 
        'defaults' => array(
                '__NAMESPACE__' => 'Documents\Controller', 
         'controller' => 'Documents\Controller\DocumentsController', 
         'action' => 'add', 
        ), 
       ) 
      ) 

      ) 
     ) 
); 

感謝

+1

您可以編輯您的問題,包括您使用的是產生這種錯誤的觀點的代碼? –

回答

0

您所定義的 '路線' 的名字是 '文件'

嘗試改變以下線

'route' => '/DocumentsController[/:action]', 

'route' => '/documents[/:action]', 


另外,在視圖文件,創建網址 - 如:

<?php echo $this->url('documents', array('action' => 'index')); ?>