I have a project created with Flash Builder 4, which uses Zend Framework to interface with a PHP script that interfaces with our MySQL database. The person that set all this up for us has left the company, so I have to try and figure this out. It looks like the Zend Framework folder is located at /var/www/ZendFramework, and in this folder there is a "library" folder and inside that is a "Zend" folder.
The amf_config.ini in the root folder of my application, which is at /var/www/html/cc/ControlCenterX.XX.XXXXXX, has these contents:
[zend]
webroot = ./
zend_path = /var/www/ZendFramework/library
[zendamf]
amf.production = false
amf.directories[]=./
and the gateway.php has these contents, which I assume is the default:
<?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();
This application works fine on our local server.
We are now migrating everything to an off-site cloud server. This cloud server has multiple virtual hosts, one for each of our local servers that we are migrating. I installed the Zend Framework by doing apt-get install zend-framework
. It looks like, by default, it installs to /usr/share/php/libzend-framework-php. I tried changing the zend_path
in amf_config.ini to that location, but I am getting a "Channel disconnected before an acknowledgement was received" error. I tried copying the ZendFramework folder from the local server to /var/www/ControlCenter on the cloud server, which is the new document root for that virtual host, and then changing the zend_path
in amf_config.ini to "/var/www/ControlCenter/ZendFramework/library", but I get the exact same result.
My Flash application is located at /var/www/ControlCenter/ControlCenterX.XX.XXXXXX, which is also the folder that contains amf_config.ini, gateway.php, and my PHP script.
It looks like the PHP function is getting called just fine. To test, I had the function create a text file. When the Flash application calls the PHP function, the text file is created, so the function is called, but it looks like there's a problem in sending the data back to the Flash application.
I am by NO means an expert at any of this kinda stuff, so please dumb your answer down as much as possible for me :-)
Thanks!
-Travis
I figured out the problem. It was actually something with the PHP file, not a configuration issue. My PHP file is structured like this:
This way, I can test the PHP function in a browser easily by calling "http://my-url.com/FLASH.php?function=testFunction¶m1=value1¶m2=value2". This worked with no problems at all on my local server, but for some reason, the new server didn't like the testing area in that file. It kept saying that "function" is undefined or something, talking about the
if ($_GET["function"])
part. So I took the testing part out and put it in a secondary file, called it testFLASH.php, and included FLASH.php in it viarequire_once("FLASH.php");
and now I can test the functions by calling testFLASH.php in the browser instead of FLASH.php.