0

젠드 프레임 워크로 시작한 것입니다. URI 라우팅에 잘못된 점이 무엇인지 잘 모르겠습니다.젠드 프레임 워크의 모듈에 대한 URI 라우팅에 문제가 있음

저는 젠드 스튜디오의 초기 htdocs 폴더 (Windows 7에서도 젠드 서버를 사용하고 있습니다)의 프로젝트를 시작합니다. 모든 항목이 인덱스 페이지를 가져 오는 작업을 잘 수행하고있는 것 같습니다 (/ public/하위 디렉토리가 부족합니다).

그러나 모듈을 추가하려고 할 때,이 경우 사용자가 Index라는 컨트롤러를 사용하고 구성을 얻는 방법에 따라 다음과 같이 URI를 가져 오려면 무엇을 넣어야하는지 잘 모르겠습니다. 보기로 연결합니다. 나는 생각할 수있는 URI 조합의 모든 구성을 시도했다. (localhost:80/public/users, localhost:80/public/users/index, localhost:80/users 등)

라우팅 오류가 발생하지 않지만 단순한 404 페이지 만 전달된다.

공용 폴더를 루트로 설정해야합니까? 아니면 라우팅을 작동시키기 위해해야 ​​할 일이 있습니까?

~ 응답 편집은 자동으로 application.config.php에 추가 않는 것 같습니다

bitWorking합니다. 하지만 여기에 사용자 모듈의 module.config.php가 있습니다.

'router' => array(
    'routes' => array(
     'users' => array(
      'type' => 'Literal', 
      'options' => array(
       // Change this to something specific to your module 
       'route' => '/index', 
       'defaults' => array(
        // Change this value to reflect the namespace in which 
        // the controllers for your module are found 
        '__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(
         ), 
        ), 
       ), 
      ), 
     ), 
    ), 
), 

이제 경로를 사용자 정의하는 방법을 안내합니다. 나는 이것에 대해서도 실험을 해왔지만, 내가 무엇을 설정해야하는지 아직 확신하지 못하고있다. 훨씬 더 가까이. 당신이 /users하여 사용자 모듈에서 색인 컨트롤러를 호출 할 경우

+0

당신은'application.config.php'에 모듈을 추가했습니다 : 같은

return array( 'modules' => array( 'Application', 'Users', ), ... 

는 그래서 URL의이 보일 것입니다 : 그것은 같이해야합니까? 그렇지 않다면'module.config.php'에서 경로를 게시하십시오 .. – bitWorking

답변

1

그에 따라 경로 이름을 가지고

그렇지
... 
'users' => array(
    'type' => 'Literal', 
    'options' => array(
     // Change this to something specific to your module 
     'route' => '/users', 
         --------- 
     ... 

application.config.php를 제어하십시오.

localhost/public/users -> Users/Controller/IndexController/indexAction 
localhost/public/users/foo -> Users/Controller/FooController/indexAction 
localhost/public/users/foo/bar -> Users/Controller/FooController/barAction 
+0

젠드 서버가 아닌 로컬 호스트를 실행하기 위해 XAMPP로 전환 한 후에 만 ​​작동하게되었습니다. Zend Server를 사용하여 URI 라우팅을 시도하지 않는 것처럼 계속 404 페이지를 유지했습니다. 구성에 문제가 있는지 잘 모르겠습니다. – cchapman