마지막으로 zf2 설치에 성공했습니다. 이제는 함수에 액세스하려고 시도하지만 404 페이지를 얻습니다.젠드 2의 컨트롤러에서 함수에 어떻게 액세스합니까?
이것은 내 코드입니다. 네임 스페이스 Application \ Controller; 나는 그것이 나 리디렉션/내 링크가 404 이유에를 추가 액세스
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class IndexController extends AbstractActionController{
public function indexAction(){
return new ViewModel();
}
public function addAction(){
echo 1;
}
public function editAction(){
}
public function deleteAction(){
}
}
?
이
는 경로입니다 : 내가 함수 addAction에 액세스 할 수있는 경로를 수정해야 할 경우return array(
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
// The following is a route to simplify getting started creating
// new controllers and actions without needing to create a new
// module. Simply drop new controllers in, and you can access them
// using the path /application/:controller/:action
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\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(
),
),
),
),
),
),
),
'service_manager' => array(
'abstract_factories' => array(
'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
'Zend\Log\LoggerAbstractServiceFactory',
),
'aliases' => array(
'translator' => 'MvcTranslator',
),
),
'translator' => array(
'locale' => 'en_US',
'translation_file_patterns' => array(
array(
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Index' => 'Application\Controller\IndexController'
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'application/index/index' => __DIR__ . '/../view/application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
),
// Placeholder for console routes
'console' => array(
'router' => array(
'routes' => array(
),
),
),
);
누군가가 나를 설명 할 수 ??? 또는 새 컨트롤러에 액세스 하시겠습니까? 예 : myproject/mynewcontroller 또는 myproject/add? 내가 젠드에서 라우팅을 사용하지 않은 이후로는,이 코드가 유효한 경우 완전히 확실하지 않다
'router' => array(
'routes' => array(
'index' => array(
'type' => 'Literal',
'options' => array(
'route' => '/add',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'add',
),
),
: 들으
내가 돈, t는 모든 기능과 컨트롤러에 대한 이해 새로운 경로를 만들어야합니까? –
예, 모든 기능과 컨트롤러에 대해 새로운 경로를 만들어야합니다. 이것이 zend MVC의 작동 방식입니다. – NoCode
방금 내 게시물을 업데이트했습니다. 다시 확인해주세요. –