我正在学习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");
}
}
应用\类\型号\ calendar.php:
Class Model_Calendar extends Model
{
public function testing($param)
{
$tst ="I want to display it: "."$param";
return $tst ;
}
}
bootstrap.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',
));
我在错误页面上检查了“环境&gt;包含的文件”我可以看到我的控制器文件: APPPATH \类\控制器\日历\ Calendar.php
如果在这种情况下Controller不在额外的目录中,那么一切正常: application \ classes \ Controller \ Calendars \ Calendar.php
我使用Xampp我的根目录:D:\ xampp \ htdocs 我的项目有别名: 别名/ organizer_tst / calendar“D:\ xampp \ htdocs \ organizer_tst”
你能告诉我为什么我有这个错误例外吗?
答案 0 :(得分:2)
Kohana's naming conventions告诉你应该如何命名和定位你的课程。
在这种情况下,Kohana正在寻找位置Controller_Calendars_Calendar
中名为application/classes/Controller/Calendars/Calendar.php
的班级。它找到文件而不是类。您应该为您的班级Controller_Calendars_Calendar
命名,或将文件移至application/classes/Controller/Calendar.php
答案 1 :(得分:0)
COntroller :blog.php 在blog.php中有一个定义如下的方法:
public function action_new()
{
$view =View::factory('blog/new');
$this->response->body($view);
}
观看次数:名为“博客”的文件夹,在博客中你有一个名为new.php的文件
按此顺序检查文件。