【发布时间】:2012-10-31 23:26:18
【问题描述】:
您好,我正在尝试将 SILEX 微框架与我自己的充满类的库一起使用,因此我遇到了 2 个加载器,导致加载器无法加载类的错误。有没有办法使用这些2 个加载器同时没有出现此错误?
我使用的加载器可以在下面找到:
<?php
/*
* Loader
*/
function my_autoloader($className)
{
// haal de base dir op.
$base = dirname(__FILE__);
// het pad ophalen
$path = $className;
// alle paden samenvoegen tot waar ik zijn moet en de phpfile eraan plakken.
$file = $base . "/lib/" . $path . '.php';
// als file bestaat haal op anders error
if (file_exists($file))
{
require $file;
}
else
{
error_log('Class "' . $className . '" could not be autoloaded');
throw new Exception('Class "' . $className . '" could not be autoloaded from: ' . $file);
}
}
spl_autoload_register('my_autoloader');
?>
silex 使用的加载器位于供应商目录中(来自框架本身)
这就是我的文件树的样子:
【问题讨论】:
标签: php autoloader