Php Kohana:Kohana_HTTP_异常[404]:在此服务器上找不到请求的URL日历
我正在学习kohana,我正在使用版本:3.3.0 我得到了这个错误:Php Kohana:Kohana_HTTP_异常[404]:在此服务器上找不到请求的URL日历,php,kohana,kohana-3.3,Php,Kohana,Kohana 3.3,我正在学习kohana,我正在使用版本: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\c
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()
我键入的URL:
(//localhost/organizer_tst/calendar/)
我的文件:
application\classes\Controller\Calendars\Calendar.php:
class Controller_Calendar extends Controller
{
public function action_index()
{
$tst = new Model_Calendar();
echo $tst->testing("LOLLOLOOLL");
}
}
Class Model_Calendar extends Model
{
public function testing($param)
{
$tst ="I want to display it: "."$param";
return $tst ;
}
}
application\classes\Model\calendar.php:
class Controller_Calendar extends Controller
{
public function action_index()
{
$tst = new Model_Calendar();
echo $tst->testing("LOLLOLOOLL");
}
}
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',
));
Kohana::init(数组)(
'基本url'=>'/organizer\u tst/',
));
路线::集合('something','calendar(/(/(/(/)))'))
->默认值(数组)(
'目录'=>'日历',
“控制器”=>“日历”,
“操作”=>“索引”,
));
路由::set('默认','(/(/))'))
->默认值(数组)(
“控制器”=>“欢迎”,
“操作”=>“索引”,
));
我在错误页面上选中了“环境->包含的文件”,我可以看到我的控制器文件:
APPPATH\classes\Controller\Calendars\Calendar.php
在这种情况下,如果控制器不在额外目录中,则一切正常:
application\classes\Controller\Calendars\Calendar.php
我使用Xampp我的根目录:D:\Xampp\htdocs
我的项目有别名:
别名/organizer\u tst/calendar“D:\xampp\htdocs\organizer\u tst”
你能告诉我为什么我有这个错误例外吗 告诉您应该如何命名和定位类
在本例中,Kohana正在location
application/classes/Controller/Calendars/Calendar.php
中查找名为Controller\u Calendars\u Calendar
的类。它找到的是文件,而不是类。您应该将类命名为Controller\u Calendars\u Calendar
或将文件移动到application/classes/Controller/Calendar.php
Controller:blog.php
在blog.php中,有一个方法定义如下:
public function action_new()
{
$view =View::factory('blog/new');
$this->response->body($view);
}
视图:一个名为“Blog”的文件夹,在Blog中有一个名为new.php的文件
按此顺序检查您的文件。您可以包括您的
.htaccess
文件吗?此外,基本url应该是完整的url,例如:http://localhost/organizer_tst/
(可能与问题无关)它现在可以工作了我更改了我的路线:route::set('calendar','calendar(/(/(/)),
array('directory'=>'(calendar))->默认值(array('controller'=>calendar\u BaseCal','action'=>'index',)代码>并将类命名为Controller\u Calendar\u BaseCal