0
我剛將我的項目從CodeIgniter 2升級到了驅動程序自動加載功能的CodeIgniter 3。我正在嘗試創建一個自定義驅動程序,但遺憾的是,文檔並沒有爲我提供執行此操作的步驟。請求的驅動程序無效
我的驅動程序在CodeIgniter 3中正常工作,但它不在2.我已根據the documentation更新了我所有的類和文件名。
我有以下文件結構:Testdriver.php的
/libraries
/Testdriver
/drivers
Testdriver_test.php
Testdriver.php
內容:Testdriver_test.php的
class Testdriver extends CI_Driver_Library
{
function __construct()
{
$this->valid_drivers = array('testdriver_test'); //Still not sure why this must be here, but the documentation doesn't explain me anything
}
function test()
{
echo "Hello world from parent driver";
}
}
內容:
class Testdriver_test extends CI_Driver
{
public function index()
{
echo "Hello world!";
}
}
自動加載驅動程序,並在pages.php中調用該函數:
$this->testdriver->test(); //This works, I can successfully call the method from the parent driver
$this->testdriver->test->index(); //This doesn't work, gives me the "Invalid driver requested" error
爲什麼在CodeIgniter 2中工作,而不再是?我該如何解決它?