me?
• PHP developer who became a flash’er MX
• Wrote majority of Zend Amf & lots of
AMFPHP
• Flash Builder 4 PHP data services
• Currently
• Scala: Akka STM
• Thrift: PHP
• Hadoop: HBase, HDFS, Hive
Every solution I've ever seen or developed in PHP feels
clunky and bulky, there is no elegance or grace. Working
with PHP is a bit like throwing a 10 pound concrete cube
from a ten story building: You'll get where you're going
fast, but it's not very elegant. ... I love PHP, and it's the right
tool for some jobs. It's just an ugly, cumbersome tool that
makes me cry and have nightmares. It's the new VB6 in a C
dress.
Fredrik Holmstrm
Digg, Wikipedia, Facebook, Stumble Upon, Flicker, Tagged,
Vimeo, iStockPhoto, FeedBurner, TechCrunch,YouTube*
Written in PHP
Wordpress, Drupal, Joomla
Written in PHP
Some of the largest sites on the internet -- sites you
probably interact with on a daily basis -- are written in
PHP. If PHP sucks so profoundly, why is it powering so
much of the internet?
The only conclusion I can draw is that building a
compelling application is far more important
than choice of language. While PHP wouldn't be my
choice, and if pressed, I might argue that it should never be
the choice for any rational human being sitting in front of a
computer, I can't argue with the results.
Jeff Atwood
Coding Horror
Why ZF?
• Use-at-will Framework
• Coding Standards / Testing Standards
• BSD License (Enterprise Friendly)
• Well Documented
• Large Community
• Plenty to integrate!
Why us Zend_Amf?
• It handles the conversion of data types between
ActionScript and PHP
• Converts complex objects and supports class
mapping
• Access Control, Authentication, ORM, Logging,
PHP controllers, another SOA endpoint.
Zend_Amf works?
• It’s a basic RPC model
• SOAP, XML-RPC, REST, etc
• Call & Response
1 1/2 year’s.....
• Zend Amf Beta was released Oct ‘08
• 226 bugs fixed w/ test cases
• 8 Features added
• 84 outstanding features / bugs
• 89% code coverage 100% method
• 14 SVN committers
• 3 Major refactors
Files: pub/.htaccess
1.RewriteEngine on
2.RewriteEngine ^(crossdomain.xml)$ pub/xml/crossdomain.xml
3.RewriteEngine ^(gateway-config.xml)$ pub/xml/gateway-
config.xml
4.RewriteEngine ^.(js|ico|gif|jpg|png|xml|swf)$ index.php
5.
6.php_flag magic_quotes_gpc off
7.php_flag register_globals off
8.php_flag display_errors on
9.
10.php_value session.auto_start 0
Files: pub/index.php
1.require_once './app/models/HelloWorld.php';
2./** Bootstrap */
3.
4.// Instantiate server
5.$server = new Zend_Amf_Server();
6.$server->setProduction(false);
7.Zend_Session::start();
8.$server->setSession();
9.
10.$server->addDirectory(dirname(__FILE__) .'/app/models/');
11.
12.// Add class to be reflected
13.$server->setClass('HelloWorld');
14.$server->setClass('contact.ContactDAO');
15.$server->setClass('contact.events.ContactDispatch');
16.$server->setClassMap('ContactVo',"Contact");
17.
18.// Handle request
19.$request = $server->handle();
20.echo($request);
Hybrid site
1.<?php
2.class GatewayController extends Zend_Controller_Action
3.{
4. public function indexAction()
5. {
6. $this->getHelper('ViewRenderer')->setNoRender();
7. $server = new Zend_Amf_Server();
8. $server->addDirectory( dirname(__FILE__) . '/../
services/' );
9. echo($server->handle());
10. }
11.}
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;
}
}
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;
}
Simple Rest
spl_autoload_register(); // don't load our classes unless we use
them
$mode = 'debug'; // 'debug' or 'production'
$server = new RestServer($mode);
// $server->refreshCache(); // uncomment momentarily to clear
the cache if classes change in production mode
$server->addClass('TestController');
$server->addClass('ProductsController', '/products'); // adds
this as a base to all the URLs in this class
$server->handle();