Menu:

Sponsor

Discover Master of Alchemy, our first iPad/iPhone and iPod touch game!

 

Forum's topics

Latest Files

Archives

Top Rated

Categories

Photo Gallery


Flex RemoteObject and AMFPHP 1.9

As you probably know Patrick Mineault has recently released a new version of amfphp which starts the support for Flex2.

In this tutorial we will see how to install the new amfphp release and how to works in flex2 with the RemoteObject tag using amfphp.

1. Download and install amfphp 1.9

First download amfphp 1.9 and unzip into your root webfolder (for example http://localhost/amfphp2).

2. Create your first service

Into the amfphp2/services create a new folder "tutorials" where we will put our php classes.

Now, into this "tutorials" folder, create a new php file: HelloWorld.php:


<?php

/**
 * First tutorial class
 */
class HelloWorld {

    
/**
     * first simple method
     * @returns a string saying 'Hello World!'
     */
    
function sayHello()
    {
        return 
"Hello World!";
    }

}

?>

Notice that unlike in previous versions of amfphp, there is no $this->methodTable in this class. The method table was eliminated in amfphp 1.9 and is now ignored.

In the new amfphp 1.9 all methods are assumed to be remotely accessible unless you declare a method starting with an underscore ("_", pythonic way) or declaring it as private (php5 only).

The javadoc style comments used in this class, both in the class declaration and in the method declaration, will be also visible in the amfphp browser.
In fact also the amfphp browser has changed, now built with flex2 too, and you can explore all your services using http://localhost/amfphp2/browser.

This is a screenshot of my browser having "HelloWorld.php" service selected:

amfphp browser

As you can see the browser will display both the class and method's javadoc comments. Like in the previous version of the browser you can also test your classes methods just using the "call" button. If your method require some arguments you will see near the call button an input field for every method's argument.