이 내 첫 번째 질문입니다,젠드 프레임 워크 2 - 일부 Begginner 질문
은 내가 ZF2 초급 그리고 난 내가 ("예에 의한 젠드 Franework 2") 다음있어 튜토리얼과 관련된 몇 가지 질문이 있습니다.
지침을 따르지만 결과를 테스트 할 때 missmatch를 연결하고 올바른 경로로 연결하지 마십시오. 내 설명.
ZF2 용 skeletonModule 구조 다음에 사용자 모듈 하나를 새로 만들었습니다. module.config.php 코드는
<?php
return array(
'controllers' => array(
'invokables' => array(
'Users\Controller\Index' =>
'Users\Controller\IndexController',
),
),
'router' => array(
'routes' => array(
'users' => array(
'type' => 'Literal',
'options' => array(
// Change this to something specific to your module
'route' => '/users',
'defaults' => array(
'__NAMESPACE__' => 'Users\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
// This route is a sane default when developing a module;
// as you solidify the routes for your module, however,
// you may want to remove it and replace it with more
// specific routes.
'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(
),
),
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'users' => __DIR__ . '/../view',
),
),
);
내 다음 단계였다 "index.phtml", "login.phtml"와 "새로운 user.phtml"라는 3로 .phtml 페이지를 만들 수 있습니다. 인덱스는 메인 페이지이며 (분명히) 다른 두 페이지와 연결되어 있습니다.
색인 코드는 다음과 같습니다
<h1>Bienvenido al modulo de usuarios</h1>
<a href="../users/index/login">Login</a> ||
<a href="../users/index/register">Registro</a>
로그인 코드는 다음과 같습니다
<h2>Login</h2>
<p>Esta página contendrá el formulario de inicio de sesión (Login).</p>
<a href="../">Volver a inicio.</a>
새로운 사용자 코드는 다음과 같습니다
<h2>Registro de nuevo usuario</h2>
<p>Esta página contendrá el formulario de registro para un nuevo usuario.</p>
<a href="../">Volver a inicio.</a>
가 여기 내 의심이다. 튜토리얼에서 href 링크는 내 것과 다릅니다. index.phtml 자습서 코드의 경우 <a href="https://stackoverflow.com/users/index/login">Login</a> || <a href="https://stackoverflow.com/users/index/register">Registro</a>
NOT <a href="../users/index/login">Login</a> || <a href="../users/index/register">Registro</a>
자습서와 같은 href 링크를 변경하면 작동하지 않고 ZF2가 다른 phtml 파일을 찾지 못하기 때문에 오류 페이지로 리디렉션됩니다. "../"와 링크를 연결하면 프로젝트가 정상적으로 작동합니다.
사진을 게시 할 수 없지만 원할 경우 프로젝트 구조 사진을 이메일에 보냅니다. 모두 4 개 감사합니다!
인가 ZF2 실행을 렌더링 할 url view helper를 사용하는 것이 좋습니다? –
ZF2가 http : // localhost/ZF2_TUTORIAL1/ – Makros