【发布时间】:2012-11-18 18:23:44
【问题描述】:
我正在尝试在实时服务器上运行我的脚本,但它正在暂存。
在本地,一切都很好(OS X),远程,CentOS/Nginx,我遇到了一个致命问题..脚本说我的自定义数据库类找不到。
查看加载的内容,使用get_declared_classes(),我绝对可以看到我的自定义数据库类,它在调用它的脚本/类之前加载。
它正在通过我的自动加载器加载:
spl_autoload_register(function ($className) {
if (file_exists(ROOT . DS . 'library' . DS . 'intranet' .DS . 'classes' . DS .strtolower($className) . '.php')){
require_once(ROOT . DS . 'library' . DS . 'intranet' .DS . 'classes' . DS .strtolower($className) . '.php');
} else if (file_exists(ROOT . DS . 'application' . DS . 'controller' . DS . strtolower($className) . '.php')) {
require_once(ROOT . DS . 'application' . DS . 'controller' . DS . strtolower($className) . '.php');
} else if (file_exists(ROOT . DS . 'application' . DS . 'model' . DS . strtolower($className) . '.php')) {
require_once(ROOT . DS . 'application' . DS . 'model' . DS . strtolower($className) . '.php');
} else if (file_exists(ROOT . DS . 'application' . DS . 'view' . DS . strtolower($className) . '.php')) {
require_once(ROOT . DS . 'application' . DS . 'view' . DS . strtolower($className) . '.php');
} else {
throw new Exception("Class: $className not autoloaded!");
}
});
没有抛出异常。
Array ( [128] => Router
[129] => debug
[130] => database
[131] => SessionManager
[132] => security
)
Fatal error: Class 'database' not found in
/home/nginx/domains/ckrisc/public/library/intranet/classes/sessionmanager.php
on line 76
引导和文件包含如下:
require_once (ROOT . DS . 'config' . DS . 'config.php' );
require_once (ROOT . DS . 'config' . DS . 'directories.config.php' );
require_once (library . DS . 'setup.php' );
require_once (library . DS . 'Autoloader.php' );
require_once (library . DS . 'Router.php' );
require_once (library . DS . 'init.php' );
在这种情况下,类database 正在从会话管理器中调用,该会话管理器在init.php 中调用。
脚本在这里失败:
$sessionId = database::getInstance()->real_escape_string($sessionId);
关于我在这里缺少什么的任何想法?
【问题讨论】:
-
在异常之前调用
get_declared_classes()。检查回溯 -
@KarolyHorvath,我做到了,它已经被加载了。
-
它是字面上的异常吗?
-
@KarolyHorvath,是的,我把它放在调用数据库类之前。我什至后来放了它,它仍然在那里。
-
你说它抛出异常之后是什么意思...
标签: php