duanquannan0593 2013-09-30 04:25
浏览 48
已采纳

zendamf无法在服务器中加载类

i am working on a flex php project where i am using zendamf to pass remotemessages. 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. if i manually add the class everything is back to normal. my gateway.php is :

<?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. Can anyone please help me how to load class automatically in server ?

  • 写回答

1条回答 默认 最新

  • doubaisui2526 2013-10-02 03:37
    关注

    solved !!! it seems PluginLoader.php of zendamf framework tries to find the corresponding service, but not by the class name. 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 !!!

    i hope it helps someone who is stuck like me :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题