简体   繁体   English

Kohana 3.3未找到Model :: factory()类

[英]Kohana 3.3 Model::factory() Class Not Found

So I am aware of the implementation of the PSR-0 standard in Kohana 3.3 . 因此,我知道Kohana 3.3中PSR-0标准的实现。 However, there must be something I am not understanding as I am getting a class not found error for the following code: 但是,由于下面的代码出现类未找到错误,一定有一些我不理解的地方:

$model = Model::factory('MyModel');

the model definition is located at: 模型定义位于:

classes/Model/MyModel.php

How is it that my class is not being found exactly? 找不到我的班怎么办?

Actual Code: 实际代码:

Model located at classes/Model/VoiceTalent.php 模型位于classes/Model/VoiceTalent.php

<?php defined('SYSPATH') or die('No direct script access.');

    class VoiceTalent
    {
         //methods and fields
    }

Controller Code: 控制器代码:

$talent = Model::factory('VoiceTalent');

Exact Error Message: 确切的错误消息:

ErrorException [ Fatal Error ]: Class 'Model_VoiceTalent' not found
SYSPATH\classes\Kohana\Model.php [ 26 ]

Your class is badly named. 您的班级名字不好。

You have: 你有:

class VoiceTalent

Should be: 应该:

class Model_VoiceTalent

as you have to include all folders it is contained within (separated by _ ) in the class name. 因为您必须包括所有文件夹,该文件夹包含在类名称中(由_分隔)。 In this case you just need to add Model_ prefix. 在这种情况下,您只需要添加Model_前缀。 You can read more about class naming convention in Kohana's docs . 您可以在Kohana的docs中阅读有关类命名约定的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM