I’m near the start of my Flex learning path and after watching Lee Brimlows video I decided it would be cool to implement the new Zend Framework version with my Flex app since it is now the recommended way to implement remoting with Flex. It took some effort to actually get it working and now that it is working, I think it might be good of me to share my learning experiences with other flex newbies so we can all benefit, it is the spirit of open source after all, right?

So, let’s start with the Zend Framework itself.  Download the framework zip file, unzip it to your PC and have an FTP client at the ready.  So, assuming you’re connected to your hosting account for your site, upload the zend folder from the downloaded framework into the a folder called ‘frameworks’ in the root folder of your hosting account.  It is important if you are following this example that you place the framework in the correct place.

That’s it!  Zend is now installed, so now you need to tell your Flex app where to look for the Zend files when it connects.  This is done with the index.php file.  So lets confirm your file structure:

Where ‘/’ is your webroot folder you should have the following

/frameworks/Zend

/mySite/amf/index.php

in the index.php file you need the following contents

error_reporting(E_ALL|E_STRICT);
ini_set("display_errors", "on");
ini_set("include_path", ini_get("include_path") . ":../../frameworks");


require_once 'Zend/Amf/Server.php';
require_once 'MyService.php';

$server = new Zend_Amf_Server();
//adding our class to Zend AMF Server
$server->setClass("MyService");
$server->setProduction(false);
echo( $server -> handle() );

This file is what brings the Zend framework into play.  Now, you also need a service file as referenced in your flex app.  Here is a copy of my service file, ‘MyService’.

class MyService
{
public function doSomething(){
//do nothing for now
}
}

Post a Comment

*
*