0

我正在学习 kohana,我正在使用 ver:3.3.0。

我收到此错误:

Kohana_HTTP_Exception [ 404 ]: The requested URL calendar was not found on this server.
SYSPATH\classes\Kohana\Request\Client\Internal.php [ 79 ]

SYSPATH\classes\Kohana\Request\Client\Internal.php [ 79 ]
SYSPATH\classes\Kohana\Request\Client.php [ 114 ] » Kohana_Request_Client_Internal->execute_request(arguments)
SYSPATH\classes\Kohana\Request.php [ 990 ] » Kohana_Request_Client->execute(arguments)
DOCROOT\index.php [ 118 ] » Kohana_Request->execute() 

我输入的网址:

(//localhost/organizer_tst/calendar/)

我的文件:

应用程序\类\控制器\日历\Calendar.php:

class Controller_Calendar extends Controller
{

    public function action_index()
    {
        $tst = new Model_Calendar();
               echo $tst->testing("LOLLOLOOLL");              
    }
}

应用程序\类\模型\日历.php:

Class Model_Calendar extends Model
{
    public function testing($param)
    {
        $tst ="I want to display it: "."$param";
        return $tst ;        
    }   
}

引导程序.php:

Kohana::init(array(
    'base_url'   => '/organizer_tst/',
));

Route::set('something', 'calendar(/<directory>(/<controller>(/<action>(/<id>))))')
    ->defaults(array(
        'directory'  => 'Calendars',
        'controller' => 'Calendar',
        'action'     => 'index',
    ));

Route::set('default', '(<controller>(/<action>(/<id>)))')
    ->defaults(array(
        'controller' => 'welcome',
        'action'     => 'index',
    ));

我在错误页面上检查了“环境->包含的文件”我可以看到我的控制器文件:APPPATH\classes\Controller\Calendars\Calendar.php

在这种情况下,如果 Controller 不在额外目录中,则一切正常: application\classes\Controller\Calendars\Calendar.php

我使用 Xampp 我的根目录:D:\xampp\htdocs 并且我的项目有别名: Alias /organizer_tst/calendar "D:\xampp\htdocs\organizer_tst"

你能告诉我为什么我有这个错误异常吗?

4

2 回答 2

2

Kohana 的命名约定告诉你应该如何命名和定位你的类。

在这种情况下,Kohana 正在寻找一个名为Controller_Calendars_Calendarlocation的类application/classes/Controller/Calendars/Calendar.php。它找到文件但没有找到类。您应该为您的班级命名Controller_Calendars_Calendar或将文件移动到application/classes/Controller/Calendar.php

于 2013-08-16T09:39:13.113 回答
0

COntroller: blog.php In blog.php there is a method defined as follows:

public function action_new()
    {
        $view =View::factory('blog/new');
        $this->response->body($view);
    }

views:A folder named "Blog" and inside blog you have a file named new.php

Check your files in this sequence.

于 2014-03-20T07:20:05.937 回答