21
Zend AMF and Flex

Zend Amf And Flex

  • Upload
    riafox

  • View
    34.950

  • Download
    4

Embed Size (px)

DESCRIPTION

Introsuction to using Zend AMF with Zend Framework and Adobe Flex

Citation preview

Page 1: Zend Amf And Flex

Zend AMF and Flex

Page 2: 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

Page 3: Zend Amf And Flex

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

Page 4: Zend Amf And Flex

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

Page 5: Zend Amf And Flex

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.

Page 6: Zend Amf And Flex

AMF Benefits

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

Page 7: Zend Amf And Flex

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

Page 8: Zend Amf And Flex

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.

Page 9: Zend Amf And Flex

Files: Root

app/

lib/

log/

pub/

tmp/

Page 10: Zend Amf And Flex

Files: app/

conf/    setupdb.sql    main.ini

models/    Contacts.php

Page 11: Zend Amf And Flex

Files: lib/

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

Riafox/    Flexstring.php    Flexstring/

Page 12: Zend Amf And Flex

Files: pub/ css/

img/    js/

swf/     main.swf

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

Page 13: Zend Amf And Flex

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

Page 14: Zend Amf And Flex

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

Page 15: Zend Amf And Flex

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;

Page 16: Zend Amf And Flex

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

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

Page 17: Zend Amf And Flex

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>

Page 18: Zend Amf And Flex

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

Page 19: Zend Amf And Flex

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

Page 20: Zend Amf And Flex

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 

Page 21: Zend Amf And Flex

Questions?

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

 How to Find Us

  

@riafox@richbreton

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