2010-10-07 115 views
1

所以我试图建立一个路径与子目录,并遵循Kerkness wiki指南,但不断收到错误。如果有人能指出我做错了什么,我将不胜感激。Kohana 3:路由与子目录错误,控制器不存在

http://kerkness.ca/wiki/doku.php?id=routing:building_routes_with_subdirectories

代码:

Route::set('default', '(<directory>(/<controller>(/<action>(/<id>))))', array('directory' => '.+?')) 
    ->defaults(array(
     'directory' => 'admin', 
     'controller' => 'main', 
     'action'  => 'index', 
    )); 

的网址:

/admin/weather/feedback 

文件:

/application/classes/controller/admin/weather/feedback.php 
class Controller_Admin_Weather extends Controller_Admin_Base { 

错误:

ReflectionException [ -1 ]: Class controller_admin_weather does not exist 

回答

3

天气需要是控制器而不是反馈。在admin文件夹中创建一个weather.php,并将该控制器设置为Controller_Admin_Weather,然后将action_action_feedback。

3

正如@mikelbring所说,你的控制器类被错误地命名。这个文件中的一个类应该叫做Controller_Admin_Weather_Feedback

你真的需要这么多的可选段在你的路线? 另外;如果没有可变元素的网址,你可以只是默认坚持这样的:

Route::set('my_route_name', 'admin/weather/feedback') 
    ->defaults(array(
     'directory' => 'admin/weather', 
     'controller' => 'feedback', 
     'action'  => 'index', 
    )); 

如果你的类是/application/classes/controller/admin/weather.php和有一个action_feedback(...)方法,你可以使用下面的路线

Route::set('my_route_name', 'admin/weather/feedback') 
    ->defaults(array(
     'directory' => 'admin', 
     'controller' => 'weather', 
     'action'  => 'feedback', 
    ));