为什么 Kohana 找不到我的控制器?

发布于 2024-10-01 23:33:48 字数 969 浏览 0 评论 0原文

我有以下控制器:

<?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 能够通过自动加载找到所有类?

alt text

如何让 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?

alt text

How can I get Kohana to find the Controller_DefaultTemplate class so I can extend Controller_Static?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱殇璃 2024-10-08 23:33:48

您必须包含具有 Controller_DefaultTemplate 定义的文件

You must include file with definition of Controller_DefaultTemplate

差↓一点笑了 2024-10-08 23:33:48

问题是我的文件名 defaultTemplate.php 是驼峰式大小写,将其更改为全小写 defaultemplate.php 使 Kohana 能够找到其中的类。

The problem was that my file name defaultTemplate.php was camel case, changing it to all-lowercase defaultemplate.php enabled Kohana to find the class inside it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文