저는 Zend Framework를 처음 사용하는 사람이고 할 일이 있습니다. 문제는 두 번째 컨트롤러에 내 경로를 구성 할 수 없다는 것입니다. 첫 번째 컨트롤러 (인덱스)는 완벽하게 작동하지만 새로운 컨트롤러는 작동하지 않습니다.ZF2에서 컨트롤러 만들기
모듈을 zftool로 생성 했으므로 "Medicaments"라는 모듈이 있습니다. 다음 url localhost/project_zend/public (또는 localhost/project_zend/public/medicaments)로 프로젝트에 액세스하려고하면 작동하고 IndexController 인 indexAction에 도착합니다. 그러나 새로운 컨트롤러 "ConfigurationController (/ modules/Medicaments/Controller/현재)에 액세스하려고하면"컨트롤러가 요청을 디스패치 할 수 없다 "고 말하면서 404 페이지에 도착합니다. .
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Medicaments\Controller\Index',
'action' => 'index',
),
),
),
'medicaments' => array(
'type' => 'segment',
'options' => array(
'route' => '/medicaments[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'__NAMESPACE__' => 'Medicaments\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(
),
),
),
),
),
'configuration' => array(
'type' => 'segment',
'options' => array(
'route' => '/configuration[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Configuration',
'action' => 'index',
),
),
),
),
),
: 사용 컨트롤러는 "약제/컨트롤러/색인"입니다하지 "약제/컨트롤러/구성"여기
파일 (/modules/Medicaments/config/module.config.php에서) 내 라우터 구성입니다
는 당신의 도움을 주셔서 감사합니다
이
URL에 "/ public"을 사용할 필요가 없습니다 – cptnk