I need to use a 3rd party PHP library and have truble using it combined with Yii.
When including the Library YiiBase::autoload() returns the following error refering to "self::$resources = PagSeguroResources::init();" in the included file PagSeguroLibrary.php:
include(PagSeguroResources.php) [<a href=‘function.include’>function.include</a>]: failed to open stream: No such file or directory
I suspect that the problem is that Yii is blocking the autoloader used in the library:
PagSeguroLibrary.php
private function __construct() {
self::$path = (dirname(__FILE__));
PagSeguroAutoloader::init();
self::$resources = PagSeguroResources::init();
self::$config = PagSeguroConfig::init();
self::$log = LogPagSeguro::init();
}
PagSeguroAutoLoader.class.php
private function __construct() {
if (function_exists('__autoload')) {
spl_autoload_register('__autoload');
}
spl_autoload_register(Array($this, 'addClass'));
}
public static function init() {
if (!function_exists('spl_autoload_register')) {
throw new Exception("PagSeguroLibrary: Standard PHP Library (SPL) is required.");
return false;
}
if (self::$loader == null) {
self::$loader = new PagSeguroAutoloader();
}
return self::$loader;
}
private function addClass($class) {
foreach(self::$dirs as $key => $dir) {
$file = PagSeguroLibrary::getPath().DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.$class.'.class.php';
if (file_exists($file) && is_file($file)) {
require_once $file;
}
}
}
I have tried changing the way the path is made in the library with no success. Is there a way to bypass Yii::autoload() or do the include in another way?
Thanks!