2014-05-21 3 views
1

젠드 프레임 워크를 찾을 수 없습니다 ...이 내 모듈 난 젠드에 새로 온 사람과이 zend경로가 나는이 문제를 해결할 수없는 2

Zend\Mvc\Router\Exception\RuntimeException File: C:\wamp\www\test\vendor\zendframework\zendframework\library\Zend\Mvc\Router\Http\TreeRouteStack.php:317 Message: Route with name "course" not found

에서 변형 예이다 나는이 없기 때문에 .config.php

<?php 

return array(
'controllers' => array(
     'invokables' => array(
     'Course\Controller\Index' => 'Course\Controller\IndexController', 
     ), ), 
    'router' => array(
     'routes' => array(
      'index' => array(
       'type' => 'Literal', 
        'options' => array(
        'route' => '/course', 
        'defaults' => array(
         'controller' => 'Course\Controller\Index', 
         'action'  => 'index' 
        ), 
       ), 
      ), 
     ) 
    ), 
       'view_manager' => array(
    'template_path_stack' => array(
     'course' => __DIR__ . '/../view/' 
    ), 
    ) 


); 

및 IndexController.php는

<?php 

namespace Course\Controller; 

use Zend\Mvc\Controller\AbstractActionController; 
use Zend\View\Model\ViewModel; 

class IndexController extends AbstractActionController{ 

    protected $courseTable; 


public function indexAction() 
    { 
    return new ViewModel(array(
      'courses' => $this->getCourseTable()->fetchAll(), 
     )); 
    } 

    public function getCourseTable() 
    { 
     if (!$this->courseTable) { 
      $sm = $this->getServiceLocator(); 
      $this->courseTable = $sm->get('Course\Model\CourseTable'); 
     } 
     return $this->courseTable; 
    } 
} 

들, 저를 도와주세요 이것에 대한 잘못된 생각.

답변

1

구성에 색인이라고하는 하나의 경로가 정의되어 있습니다. '코스'라고 부르기를 원한다면 이름을 바꿔야합니다. 나는 당신의 설정에서 경로 이름을 강조했습니다

'router' => array(
    'routes' => array(
     'index' => array(// <-- this array key is the route name 
      'type' => 'Literal', 
       'options' => array(
       'route' => '/course', 
       'defaults' => array(
        'controller' => 'Course\Controller\Index', 
        'action'  => 'index' 
       ), 
      ), 
     ), 
    ) 
), 
+0

하지만 난 이름을 변경하는 경우, 다음이 오류를 참조하십시오 치명적인 오류 : 젠드 \ MVC \ 라우터 \ 예외 \의 RuntimeException의를 : 경로 이름으로 "인덱스"를하지 C : \ wamp \ www \ test \ vendor \ zendframework \ zendframework \ library \ Zend \ View \ Helper \ Navigation \ AbstractHelper.php 169 에 나와 있습니다. 자세한 내용을 알려 주시면 감사하겠습니다. – user3661744

+1

보기에서 두 개의 다른 이름으로 경로를 언급하는 것 같습니다. 당신은 일관성이 있어야합니다. –

관련 문제