2014-07-18 85 views
0

目前正在使用HMVC笨HMVC路线

的HMVC应用一个笨应用程序包含

$route['finance/bill/add'] = 'finance/show_addBill'; 

$route['finance/transaction/add'] = 'finance/show_addTransaction'; 

$route['finance/(:any)'] = 'finance/$1'; 

$route['finance'] = 'finance'; 

的应用程序有一个财务总监自己routing.php。 当去

http://localhost/finance** it goes to **public function index(){} 

http://localhost/finance/transaction/add DOES NOT go to **public function show_addTransaction() {} 

http://localhost/finance/addTransaction DOES goes to **public function show_addTransaction() {} 

我想不通为什么上面的路线不工作:S

回答

1

你不应该定义路由在HMVC应用程序(如拇指的一个非常强大的规则 - 有是例外,但很少见)。

你应该有一个文件夹结构,如:

Modules 
- Finance 
- - Controllers 
- - - finance //should have index, add and an other generic functions. 
- - - transaction // transactions specific functions 
- - - bill // bill specific functions. 

路由是自动的 - 沿着这些线路:

url/finance - >寻找Modules/Finance/Controllers/Finance/Index()

url/finance/bill - >它会寻找Modules/Finance/Controllers/Finance(.php)/Bill() FIRST then Modules/Finance/Controllers/Bill(.php)/index()

因此对于您的sc enario你应该有:

$route['finance/bill/add'] 

一个bill.php控制器 - 与class bill - 一个方法add

$route['finance/transaction/add'] 

一个transaction.php控制器 - 与class transaction - 一个方法add

$route['finance/(:any)'] 

隐而不宣”存在 - 正如我所说的URL路由是自动的,所以只要你有È相关控制器和方法的东西会被发现

$route['finance'] 

简单finance.php控制器index方法。