我正在尝试运行一个开源 Web 应用程序。它来自这里 - https://sourceforge.net/projects/labshare-sahara/ 它使用 Zend PHP 框架。
我的问题在于以下代码。它无法找到文件,因此返回 false,并且消息:
“2012-08-20T00:01:08+02:00 DEBUG (7): Unable to find auth class SAHARANS_Auth_Type_Database in include path”
输出到日志文件。
private function _loadClass($name)
{
/* Find the class to load. */
$file = implode('/', explode('_', $name)) . '.php';
foreach (explode(PATH_SEPARATOR, get_include_path()) as $path)
{
$this->_logger->debug("does $path/$file exist?"); //I added this
if (file_exists($path . PATH_SEPARATOR . $file))
{
return new $name();
}
}
$this->_logger->debug("Unable to find auth class $name in include path.");
return false;
}
为了提供更多上下文,我让它在日志中打印更多信息 - 所以它每次在 for 循环中写入日志。这是输出:
2012-08-20T00:47:07+02:00 DEBUG (7): does C:\xampp\htdocs\Sahara-WI\WI\application/../library/SAHARANS/Auth/Type/Database.php exist?
2012-08-20T00:47:07+02:00 DEBUG (7): does C:\xampp\htdocs\Sahara-WI\WI\library/SAHARANS/Auth/Type/Database.php exist?
2012-08-20T00:47:07+02:00 DEBUG (7): does C:\xampp\htdocs\Sahara-WI\WI\application\models/SAHARANS/Auth/Type/Database.php exist?
2012-08-20T00:47:07+02:00 DEBUG (7): does C:\xampp\htdocs\Sahara-WI\WI\institution/SAHARANS/Auth/Type/Database.php exist?
2012-08-20T00:47:07+02:00 DEBUG (7): does ./SAHARANS/Auth/Type/Database.php exist?
2012-08-20T00:47:07+02:00 DEBUG (7): does C:\xampp\php\PEAR/SAHARANS/Auth/Type/Database.php exist?
2012-08-20T00:47:07+02:00 DEBUG (7): Unable to find auth class SAHARANS_Auth_Type_Database in include path
2012-08-20T00:47:07+02:00 DEBUG (7): does C:\xampp\htdocs\Sahara-WI\WI\application/../library/Sahara/Auth/Type/Database.php exist?
2012-08-20T00:47:07+02:00 DEBUG (7): does C:\xampp\htdocs\Sahara-WI\WI\library/Sahara/Auth/Type/Database.php exist
2012-08-20T00:47:07+02:00 DEBUG (7): does C:\xampp\htdocs\Sahara-WI\WI\application\models/Sahara/Auth/Type/Database.php exist?
注意:Database.php 确实存在于 models\Sahara\Auth\Type 目录中!
立即看起来很奇怪的是路径中的“/”和“\”之间的互换,但试图强制反弹(我使用的是 Windows 机器)似乎没有任何影响。
提前致谢!