This document discusses advanced data communication between PHP and Flash using Zend AMF. It provides an overview of Zend AMF features like fast serialization, authentication, authorization using ACL, and database integration. It also outlines future plans to improve documentation, implement long polling, optimize performance, and develop a service browser. Resources are listed for downloading Zend AMF, Flash Builder, and reading additional articles on using Zend AMF with PHP and Flash.
1. Advanced Data Communication with the Flash Platform
twitter.com/wadearnold
wadearnold.com
wade.arnold@t8design.com
2. resources
Zend AMF Downloads
http://framework.zend.com/download/amf
Adobe Flash Builder 4 beta 2
http://labs.adobe.com/technologies/flashbuilder4/
New PHP Features in Flash Builder 4 - Part 1: Data-Centric Feature Overview
http://ria.dzone.com/articles/new-php-features-flash-builder
New PHP Features in Flash Builder 4 - Part 2: Using Zend AMF and Flash Remoting
http://ria.dzone.com/articles/new-php-features-flash-builder-2
Session Files
http://wadearnold.com/blog/
3. Why AMF?
• Binary + referencing = fast wire speed
• One CPU cycle and it can be rendered
• No parsing time on the cpu
• No parsing logic w/ the developer
• Alternative endpoint in your SOA
architecture
5. One year.....
• Zend Amf was released into ZF incubator
at ZendCon ‘08
• 96 bugs fixed
• 6 Features added
• 44 outstanding features / bugs
• 89% of code coverage
• 7 SVN committers
6. DB Resource Plugin
• Mysqli Result
• Mysql Result
public function getArrayCollection() {
$this -> connect();
$sql = "SELECT * FROM census " .
"LIMIT 100";
$result = mysql_query( $sql ) or die( "Query failed: " .
mysql_error() );
return $result;
}
8. Create Auth Adapter
class RemoteUser extends Zend_Amf_Auth_Abstract
{
public function __construct($name, $role)
{
$this->_name = $name;
$this->_role = $role;
}
public function authenticate()
{
$id = new stdClass();
$id->role = $this->_role;
$id->name = $this->_name;
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS,
$id);
}
}
9. bootstrap
$this->_server = new Zend_Amf_Server();
$this->_acl = new Zend_Acl();
$this->_server->setAuth(new RemoteUser("wade", "testrole"));
$this->_acl->addRole(new Zend_Acl_Role("testrole"));
$this->_acl->allow("testrole", null, null);
$this->_server->setAcl($this->_acl);
10. Basic Service
class demo {
function hello() {
return "hello!";
}
function hello2() {
return "hello2!";
}
function initAcl(Zend_Acl $acl) {
$acl->allow("testrole", null, "hello");
$acl->allow("testrole2", null, "hello2");
return true;
}
}
11. More Auth & ACL!
• Open ID
• Ldap
• Database
• Conditional rules
17. Model
package com.t8.census.vo <?php
{ class Person
[Bindable] {
[RemoteClass(alias="Person")] public $id = 0;
public class PersonVO public $age = "";
{ public $classofworker = "";
public var id:int = 0; public $education = "";
public var age:int; public $maritalstatus = "";
public var classofworker:String; public $race = "";
public var education:String; public $sex = "";
public var maritalstatus:String; }
public var race:String;
public var sex:String;
}
}