[英]zendamf can't load class in server
i am working on a flex php project where i am using zendamf to pass remotemessages. 我正在一个Flex php项目中,我正在使用zendamf传递远程消息。 Everything works fine on my localhost, but when i upload the zendframework as well as the services, it seems gateway.php can't find my services on server.
一切都可以在我的本地主机上正常运行,但是当我上传zendframework和服务时,gateway.php似乎无法在服务器上找到我的服务。 if i manually add the class everything is back to normal.
如果我手动添加该类,一切将恢复正常。 my gateway.php is :
我的gateway.php是:
<?php
ini_set("display_errors", 1);
$dir = dirname(__FILE__);
$webroot = $_SERVER['DOCUMENT_ROOT'];
$configfile = "$dir/amf_config.ini";
//default zend install directory
$zenddir = $webroot. '/ZendFramework/library';
//Load ini file and locate zend directory
if(file_exists($configfile)) {
$arr=parse_ini_file($configfile,true);
if(isset($arr['zend']['webroot'])){
$webroot = $arr['zend']['webroot'];
$zenddir = $webroot. '/ZendFramework/library';
}
if(isset($arr['zend']['zend_path'])){
$zenddir = $arr['zend']['zend_path'];
}
}
// Setup include path
//add zend directory to include path
set_include_path(get_include_path().PATH_SEPARATOR.$zenddir);
// Initialize Zend Framework loader
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
// Load configuration
$default_config = new Zend_Config(array("production" => false), true);
$default_config->merge(new Zend_Config_Ini($configfile, 'zendamf'));
$default_config->setReadOnly();
$amf = $default_config->amf;
// Store configuration in the registry
Zend_Registry::set("amf-config", $amf);
// Initialize AMF Server
$server = new Zend_Amf_Server();
$server->setProduction($amf->production);
if(isset($amf->directories)) {
$dirs = $amf->directories->toArray();
foreach($dirs as $dir) {
// get the first character of the path.
// If it does not start with slash then it implies that the path is relative to webroot. Else it will be treated as absolute path
$length = strlen($dir);
$firstChar = $dir;
if($length >= 1)
$firstChar = $dir[0];
if($firstChar != "/"){
// if the directory is ./ path then we add the webroot only.
if($dir == "./"){
$server->addDirectory($webroot);
}else{
$tempPath = $webroot . "/" . $dir;
$server->addDirectory($tempPath);
}
}
else{
$server->addDirectory($dir);
}
}
}
// Initialize introspector for non-production
if(!$amf->production) {
$server->setClass('Zend_Amf_Adobe_Introspector', '', array("config" => $default_config, "server" => $server));
$server->setClass('Zend_Amf_Adobe_DbInspector', '', array("config" => $default_config, "server" => $server));
}
// Handle request
echo $server->handle();
if i add this two lines to manually set class then it works fine 如果我将这两行添加到手动设置的类中,那么它将正常工作
require_once 'services/serviceTest.php';
$server->setClass("serviceTest");
most confusing part is the default gateway.php works fine in localhost. 最令人困惑的部分是默认的gateway.php在localhost上可以正常工作。 Can anyone please help me how to load class automatically in server ?
谁能帮我如何在服务器中自动加载类?
solved !!! 解决了 !!! it seems PluginLoader.php of zendamf framework tries to find the corresponding service, but not by the class name.
似乎zendamf框架的PluginLoader.php试图找到相应的服务,但没有按类名查找。 for example: my class name was "serviceTest" so plugin loader tried to find out the service named "ServiceTest.php" i changed the php file name (made the first character uppercase) and it works !!!
例如:我的类名是“ serviceTest”,因此插件加载程序试图找出名为“ ServiceTest.php”的服务,所以我更改了php文件名(使第一个字符大写),并且可以正常工作!
i hope it helps someone who is stuck like me :) 我希望它可以帮助像我这样受困的人:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.