好人好!!
我有一个基于Zend Framework 1.11.12(从1.10.8升级而来)的web应用程序(我的第一个此类应用程序),使用"模块化方法"文件夹结构,我的意思是所有模块都在application/modules
下。我使用了条令1.2.4
除了2:CKEditor
和PGRFilemanager
之外,我还将library
文件夹用于包括ZF在内的所有第三方库。pgrfile管理器,用于从管理面板将文件上传到images文件夹。这是我的全局文件结构。
/application
/configs
application.ini
routes.ini
/layouts
/scripts
/partials
*.all_the_partials_files.phtml
*.all_the_layouts.phtml
/modules
all_the_module_folders
Boostrap.php
/logs
/library
/Zend
/Doctrine
/SwiftMailer
/Abra //where all my classes reside
/Model
User.php
Role.php
other_doctrine_entities_class
/public
/javascript
/css
/images
.htaccess // added an htaccess file here
/fonts
`/ckeditor`
a_lot_of_files_including_php_files
other_folders
/plugins
other_folders
`/pgrfilemanager`
/php
auth.php
myconfig.php
other_folders_and_files_including_php
index.php
.htaccess
在我开发这个网站的时候,我没有使用Zend_Acl,所以/public/ckeditor/plugins/pgrfilemanager/php/auth.php
中的session_start()在一段时间内运行良好,因为pgrfilemanager带有默认的身份验证功能。但一旦我开始使用Zend_Acl,当从~~/auth.php
文件调用session_start()
时,我就会遇到类似Class __PHP_Incomplete_Class has no unserializer Array
异常的问题。我最初认为这是因为我没有使用Zend_Session
,但显然我是因为这里解释了这个事实(如果我错了,请纠正我,谢谢)
如何使用它?感谢阅读
既然我找到了解决这个问题的方法,我想我会分享,也许我会得到更好的视角。
Class __PHP_Incomplete_Class has no unserializer Array
的答案现在很清楚了,因为Session知道unserialize
的哪种格式意味着php必须知道会话中存储的对象的定义。
根据文件结构,我创建了一个身份验证文件,比如/public/ckeditor/puglins/pgrfilemanager/userfiles
中的myauth.php
,我将引用该路径为pgr/userdir
$path = realpath("../../../../library");
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require "Zend/Loader/Autoloader.php";
require_once 'Doctrine/Doctrine.php';
spl_autoload_register(array("Doctrine", "autoload"), true);
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace(array("Abra_"));
/*$p seem to be empty throwing error on Zend_Config_Ini but returns the config anyway.I never figured out
*/
$p = realpath("./../../../../application/configs/application.ini");
try {
// $config = parse_ini_file($p, "production");
$config = new Zend_Config_Ini($p, "production");
$conn = Doctrine_Manager::connection($config->doctrine->dsn);
$user = new Abra_Model_User();
$role = new Abra_Model_Role();
$auth = Zend_Auth::getInstance();
if(!$auth->hasIdentity()|| !in_array($auth->getIdentity()->Role->name, array("superadmin","administrator")) ){
die("Not authenticated");
}
} catch (Exception $ex) {
*/
$p = realpath("./../../../../application/configs/application.ini");
try {
// $config = parse_ini_file($p, "production");
$config = new Zend_Config_Ini($p, "production");
$conn = Doctrine_Manager::connection($config->doctrine->dsn);
$user = new Abra_Model_User();
$role = new Abra_Model_Role();
$auth = Zend_Auth::getInstance();
if(!$auth->hasIdentity()|| !in_array($auth->getIdentity()->Role->name, array("superadmin","administrator")) ){
die("Not authenticated");
}
} catch (Exception $ex) {
}
}
在pgr/php/folders.php
和pgr/php/files.php
中,我包括
$path = realpath("../../../../library");
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
顶部。则我将CCD_ 17包括在CCD_
include_once dirname(__FILE__) . '/userfiles/myauth.php';
我希望这能帮助到别人。感谢