为什么 Kohana 找不到我的控制器?
我有以下控制器:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Static extends Controller_DefaultTemplate {
public function action_index()
{
View::set_global('message', '<span class="highlight">This is a global message.</span>');
$data = array (
'siteTitle' => 'Kohana Test Site',
'siteSubtitle' => 'A site to learn Kohana',
'menu' => View::factory('blocks/menu'),
);
$view = View::factory('templates/layout', $data);
$this->request->response = $view->render();
}
}
但 kohana 给了我错误:
ErrorException [致命错误]:类 找不到“Controller_DefaultTemplate”
,并且我认为 Kohana 能够通过自动加载找到所有类?
如何让 Kohana 找到 Controller_DefaultTemplate 类,以便我可以扩展 Controller_Static?
I have the following controller:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Static extends Controller_DefaultTemplate {
public function action_index()
{
View::set_global('message', '<span class="highlight">This is a global message.</span>');
$data = array (
'siteTitle' => 'Kohana Test Site',
'siteSubtitle' => 'A site to learn Kohana',
'menu' => View::factory('blocks/menu'),
);
$view = View::factory('templates/layout', $data);
$this->request->response = $view->render();
}
}
but kohana gives me the error:
ErrorException [ Fatal Error ]: Class
'Controller_DefaultTemplate' not found
although Eclipse can find the file (via F3) and I thought Kohana was able to find all classes via autoloading?
How can I get Kohana to find the Controller_DefaultTemplate class so I can extend Controller_Static?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须包含具有
Controller_DefaultTemplate
定义的文件You must include file with definition of
Controller_DefaultTemplate
问题是我的文件名
defaultTemplate.php
是驼峰式大小写,将其更改为全小写defaultemplate.php
使 Kohana 能够找到其中的类。The problem was that my file name
defaultTemplate.php
was camel case, changing it to all-lowercasedefaultemplate.php
enabled Kohana to find the class inside it.