registering different autoloader

Hello all,

I need to use some API methods from Piwik web analytics in my Yii app and i need to register Piwik’s autoload. I’v created widget called Pwk and i got this code in its init method:




        define('PIWIK_INCLUDE_PATH', (dirname(dirname(Yii::app()->basePath))).'/piwik');           

        include_once PIWIK_INCLUDE_PATH.'/core/Loader.php';

        spl_autoload_unregister(array('YiiBase','autoload'));        

        spl_autoload_register(array('Piwik_Loader','autoload'));

          Calling_Piwiks_Api_Functions_Here();

        spl_autoload_unregister(array('Piwik_Loader','autoload'));

        spl_autoload_register(array('YiiBase','autoload'));        



Then in controllers view i got this:




$this->widget('Pwk');

$this->widget('OtheWidget');



The problem is that i am getting PHP error:


require(OtherWidget.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory

If i comment out calling Pwk widget then everythings work fine…

Any advice on what am i doing wrong? thx for answers!

So i did little workaround and changed code to this…:




        define('PIWIK_INCLUDE_PATH', (dirname(dirname(Yii::app()->basePath))).'/piwik');           

        

        spl_autoload_unregister(array('YiiBase','autoload'));        

        include_once PIWIK_INCLUDE_PATH.'/index.php';

          Calling_Piwiks_Api_Functions_Here();


        spl_autoload_register(array('YiiBase','autoload')); 



And now im getting fatal error: Class ‘CHttpCookie’ not found…

Any advice?

As per the cookbook, you were close with your original post. Try this:




define('PIWIK_INCLUDE_PATH', (dirname(dirname(Yii::app()->basePath))).'/piwik');           

include_once PIWIK_INCLUDE_PATH.'/core/Loader.php';

spl_autoload_unregister(array('YiiBase','autoload'));        

spl_autoload_register(array('Piwik_Loader','autoload'));

   Calling_Piwiks_Api_Functions_Here();

spl_autoload_register(array('YiiBase','autoload'));