Import/include Files - Third Party Libraries

Hi All,

I have a problem related to include the code from a third party. I have followed this wiki article but I don’t get to solve the problem.

The third party code has the following important files:

../provider/PPBootstrap.php




    require 'PPAutoloader.php';

    PPAutoloader::register();



../provider/PPAutoloader.php




class PPAutoloader {

    private static $map = array (

        'class' => 'route',

        '...'=>'...',

    );


    public static function loadClass($class) {

        $class = strtolower(trim($class, '\\'));


        if (isset(self::$map[$class])) {

            require dirname(__FILE__) . '/' . self::$map[$class];

        }

    }


    public static function register() {

        spl_autoload_register(array(__CLASS__, 'loadClass'), true);

    }

}



Using a pure PHP application (without Yii), I only need to inlude this line:




require_once('PPBootStrap.php');



In order to access to every class included in the class map PPAutoloader.php

Trying to using this with Yii, in a controller I have included this lines:




Yii::import('application.vendors.*');

require_once('provider/PPBootStrap.php');



Unfortunately I always get the typical error:




Error 500

YiiBase::include(Receiver.php) [function.YiiBase-include]: failed to open stream: No such file or directory



Due to the third party files are not included correctly.

What I’m doing wrong? any suggestion is welcome!

Thanks!

Try this:


Yii::import('application.vendors.provider.PPAutoloader');

Yii::registerAutoloader(array('PPAutoloader', 'loadClass'));

That works!!! great!!! Your incredible! Thank you so much :)