遇到错误无法加载请求的 class: Sistema [No AutoLoad] CodeIgniter

An Error Was Encountered Unable to load the requested class: Sistema [No AutoLoad] CodeIgniter

所以,我按照教程修改了代码,但有一点我无法修复,不明白为什么 CI 没有加载 class. 这是函数:

function set_theme($propriedade, $valor, $replace = TRUE){
    $ci =& get_instance();
    $ci->load->library('sistema');
    if($replace){
        $ci->sistema->theme[$propriedade] = $valor;
    }else{
        if (!isset($ci->sistema->theme[$propriedade])) {
            $ci->sistema->theme[$propriedade] = "";
        }
    $ci->sistema->theme[$propriedade] .= $valor;
   }
} // <-- end set_theme -->

而 class sistema.php 是:

<?php

class MY_Sistema{
    protected $ci;
    public $theme = array();

    public function __construct(){
        $this->ci =& get_instance();
        $this->ci->load->helper('functions');
    }
}

当我在控制器上调用 set_theme() 它时,它只是给出错误:

An Error Was Encountered  Unable to load the requested class: Sistema

有人知道如何修复它吗?

将您的图书馆重命名为 Sistema 并将其放入 application/libraries 文件夹

class Sistema
{
    protected $ci;
    public $theme = array();

    public function __construct(){
        $this->ci =& get_instance();
        $this->ci->load->helper('functions');
    }
}

您可以找到加载库的文档here