Zend Amf And Flex

Preview:

DESCRIPTION

Introsuction to using Zend AMF with Zend Framework and Adobe Flex

Citation preview

Zend AMF and Flex

Zend Framework

Web site: http://framework.zend.comZend Framework (ZF) is an open source, object-oriented web application framework implemented in PHP 5 and licensed under the New BSD License.  ZF was publicly announced at the first Zend Conference in October 2005. On July 1, 2007, Zend Framework 1.0 was released. Current Version 1.7.7http://framework.zend.com/download/latest

Why are people using Zend?

• Use-at-will Framework• Provides components for MVC, Table Data Gateway and

Row Data Gateway design patterns• All components in Zend Framework are object oriented• Takes advantage of the latest development features

o AJAXo Search Engineo Web Services

• BSD License (Enterprise Friendly)• Well Documented

Adobe Flex

http://www.adobe.com/products/flex/ Flex is an open source framework used to create cross-platform Rich Internet Applications (RIA)  Adobe Released Flex 1.0 in March of 2004  Current SDK: 3.3 Flex Builder IDE based on Eclipse

AMF Action Message Format

 Action Message Format is an object exchange binary format accessed through a Remote Procedure Call (RPC) Adobe Systems published the AMF binary data protocol specification on December 13, 2007 and announced that it will support the developer community to make this protocol available for every major server platform.

AMF Benefits

1. AMF Objects are small compressed using zlib2. Fast serialization / deserialization3. Native Types and Custom classes supported

http://www.jamesward.com/blog/2007/04/30/ajax-and-flex-data-loading-benchmarks/

Zend AMF

 Info: http://framework.zend.com/manual/en/zend.amf.html  Download: http://framework.zend.com/download/amf

Zend_Amf provides support for Adobe's Action Message Format (AMF), to allow communication between Adobe's Flash Player and PHP. Specifically, it provides a gateway server implementation for handling requests sent from the Flash Player to the server and mapping these requests to object and class methods and arbitrary callbacks.

Files: Root

app/

lib/

log/

pub/

tmp/

Files: app/

conf/    setupdb.sql    main.ini

models/    Contacts.php

Files: lib/

Zend/    Acl.php    Acl/    .........

Riafox/    Flexstring.php    Flexstring/

Files: pub/ css/

img/    js/

swf/     main.swf

xml/    crossdomain.xml    gateway-config.xml .htaccessindex.php

Files: pub/xml/crossdomain.xml <cross-domain-policy><allow-access-from domain="zendamf.riafox.com" /></cross-domain-policy>

Files: pub/.htaccess RewriteEngine onRewriteRule ^(crossdomain.xml)$ pub/xml/crossdomain.xml [L]RewriteRule ^(gateway-config.xml)$ pub/xml/gateway-config.xml [L]RewriteRule !\.(js|ico|gif|jpg|png|xml|swf)$ index.php

php_flag magic_quotes_gpc offphp_flag register_globals offphp_flag display_errors on

php_value session.auto_start 0

Files: pub/index.html  error_reporting(E_ALL|E_STRICT);date_default_timezone_set('America/Boise');

$rootPath = dirname($_SERVER["DOCUMENT_ROOT"]);define('APPLICATION_PATH', $rootPath . '/application');set_include_path('.' . PATH_SEPARATOR . $rootPath.'/library'. PATH_SEPARATOR . $rootPath.'/application/models/'. PATH_SEPARATOR . $rootPath.'/application/library/'. PATH_SEPARATOR . APPLICATION_PATH . '/library/App/View/Helper/'. PATH_SEPARATOR . get_include_path());

session_save_path(APPLICATION_PATH . '/temp');

include "Zend/Loader.php";$server = new Zend_Amf_Server();$server->setProduction(false);$server->addDirectory('../application/models/');$response = $server->handle();  echo $response;

Files: app/models/Test.php <?phpclass Test{

  public  function hello($text) {    return "Message Received:{$text}";  }}?> 

services-config.xml<?xml version="1.0" encoding="UTF-8"?><services-config>    <services>        <service id="amfphp-flashremoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage">            <destination id="zend">                <channels>                    <channel ref="my-zend"/>                </channels>                <properties>                    <source>*</source>                </properties>            </destination>        </service>    </services>    <channels>        <channel-definition id="my-zend" class="mx.messaging.channels.AMFChannel">            <endpoint uri="http://zendamf.riafox.com/gateway.amf" class="flex.messaging.endpoints.AMFEndpoint"/>        </channel-definition>    </channels></services-config>

compiler settingsadd -services "C:\path-to-services\services-config.xml"

main.mxml

<mx:RemoteObject id="myservice"    fault="faultHandler(event)"    showBusyCursor="true"    source="Test"    destination="zend">        <mx:method name="hello" result="responseHandler(event)" />    </mx:RemoteObject>  http://zendamf.riafox.com/public/test/main.html

Resources

• The ABCs of AMF Format• Ajax and Flex Data Loading Benchmarks• Wade Arnold Blog Zend AMF• ZF Programmer's Reference Guide• AMF3 Specifications• Latest Zend Framework Download • Zend AMF Download• Adobe 3.3 Language Reference 

Questions?

http://www.slideshare.net/riafox/zend-amf-and-flex

 How to Find Us

  

@riafox@richbreton

@ben_whitakerWeb site: http://www.riafox.com

Recommended