registerAutoloader

Can someone guide me on how to properly use the registerAutoloader() function? I have a third part class and I put it to protected/vendors.

In the controller class under components folder I added the following code

function Load(){

        include_once Yii::app()->basePath.'/vendors/PFBC/Form.php';


    }


    


    function init() {


        parent::init();


        Yii::registerAutoloader('Load', true);


    }

This doesn’t work. It says

Function ‘Load’ not found (function ‘Load’ not found or invalid function name)

Can someone help me please?

First parameter of Yii::registerAutoloader() must be a valid callback.

In your case:


Yii::registerAutoloader(array($this, 'Load'), true);

But don’t bother with an autoloader when all you need is to load a single class:




public function init()

{

  parent::init();

  Yii::import('application.vendors.PFBC.Form');

}