2013-01-10 6 views
0

설명서를 읽었지만 URI를 모듈로 라우팅하는 방법을 찾을 수없는 것 같습니다.모듈로 어떻게 라우팅 할 수 있습니까?

내 모듈에는 현재 올바른 디렉토리 구조 (현재는 수천 개의 빈 디렉토리)를 사용하는 단일 컨트롤러가 포함되어 있습니다. 내 컨트롤러는 modules/module_name/classes/controller 안에 있고 내 경로 파일은 modules/module_name/config/routes.php 안에 있습니다. 컨트롤러는 같은 아래 보이는

<?php 
return array(
    '_root_' => 'md5_encrypt/index', // The default route 

    'tools/geek/md5_encrypt' => array('md5_encrypt'), 
); 

(하지만 난 그 관련되어 있다고 생각하지 않습니다) :

은 내가 모두 /app/config/routes.phpmodules/module_name/config/routes.php에 다음과 같은 시도

<?php 

/** 
* MD5 Encrypt Controller. 
* 
* Online tool to encrypt a string using MD5 
* 
* @package app 
* @extends Controller 
*/ 

namespace Md5_encrypt; 

class Controller_Md5_Encrypt extends Controller_Template 
{ 

    /** 
    * The tool 
    * 
    * @access public 
    * @return Response 
    */ 
    public function action_index() 
    { 
     $data = array(); 
     $this->template->tab = 'geek'; 
     $this->template->title = 'MD5 Encrypt Tool'; 
     $this->template->content = View::forge('welcome/index', $data);  
    } 
} 

답변

1

당신은 할 수 없습니다 네임 스페이스 이름에 밑줄이 있어야합니다. 컨트롤러 이름과 동일합니다.

자동 로더는 파일을 찾을 때 밑줄을 디렉토리 분리 기호로 변환합니다.

+0

고마워요,하지만 고칠 수는 없습니다. 나는 그것이 일하고 있었던 길이었던 것은 잘못했을 것이다라고 생각할 것이다. – Mike

0

먼저 앱에서 응용 프로그램 모듈의 경로를 설정해야합니다/설정/config.php를

'module_paths' => array(
    APPPATH.'modules'.DS, // path to application modules 
) 

응용 프로그램 그러나/설정/routes.php

'tools/geek/md5_encrypt' => 'md5_encrypt(module_name)/md5_encrypt(controller)', 

의 두 번째 세트 라우팅, 이후 컨트롤러 이름 class Controller_Md5_Encrypt extends Controller_Template에 밑줄을 사용하면 새 경로가 나타납니다.

/modules/md5_encrypt/classes/controller/md5/encrypt.php 

밑줄 (_) 귀하의 컨트롤러의 이름으로http://fuelphp.com/docs/general/coding_standards.html#classes

귀하의 /modules/md5_encrypt/classes/controller/md5_encrypt.php 파일이 자동 로딩 중에 찾을 수 없습니다 자동 로딩 중 디렉토리 분리로 전환했다.

관련 문제