当我尝试在 CodeIgniter 中使用驱动程序时出现错误

getting error when I try to use Drivers in CodeIgniter

我试图在 codeigniter 中创建自定义驱动程序,但出现错误。

这是文件层次结构:

 /libraries
    /libraries/Taker
        /libraries/Taker/Taker.php
        /libraries/Taker/drivers
            /libraries/Taker/drivers/Taker_test.php

代码在libraries/Taker/Taker.php:

   class Taker extends CI_Driver_Library  {
        function hello() {
            echo 123;
        }
    }

代码在libraries/Taker/drivers/Taker_test.php:

class Taker_test extends CI_Driver {
    function world() {
        echo 123;
    }
}

控制器中的代码:

$this->load->driver('taker');
$this->taker->hello(); //work
$this->taker->test->world(); //eror here

我在控制器中遇到的错误:

Invalid driver requested: Taker_test

有什么建议吗? 谢谢

解决方案是我必须使用 $this->valid_drivers:

class Taker extends CI_Driver_Library  {
    
    function __construct() {
          $this->valid_drivers = ['test'];
     }
    
    
    function hello() {
        echo 123;
    }
}