2013-09-30 298 views
0

我正在使用zendamf傳遞remotemessages的flex php項目。一切工作正常我的本地主機,但是當我上傳zendframework以及服務,似乎gateway.php無法在服務器上找到我的服務。如果我手動添加類,一切都恢復正常。 我gateway.php是:zendamf無法加載服務器中的類

<?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(); 

如果我添加此兩行手動設置類,那麼它工作正常

require_once 'services/serviceTest.php'; 
$server->setClass("serviceTest"); 

最令人困惑的部分是gateway.php在本地主機工作正常的默認值。任何人都可以請幫助我如何在服務器中自動加載類?

回答

0

解決了! 似乎zendamf框架的PluginLoader.php試圖找到相應的服務,但不是通過類名。 例如: 我的班級名稱是「serviceTest」 因此,插件加載器試圖找到名爲「ServiceTest.php」的服務 我改變了PHP文件名(使第一個字符大寫),它的工作原理!

我希望它能幫助像我這樣卡住的人 :)

相關問題