0

我正在尝试在实时服务器上运行我的脚本,但它正在暂存。

在本地,一切都很好(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是从 sessionmanager 调用的,它在 init.php.

脚本在这里失败:

$sessionId = database::getInstance()->real_escape_string($sessionId);

关于我在这里缺少什么的任何想法?

4

2 回答 2

0

也许您在声明自动加载函数之前调用了该类。

于 2012-11-18T18:38:30.080 回答
0

事实证明 APC 3.1.13 引起了一些问题

于 2012-11-23T16:13:28.337 回答