hide side navigation
    5 most recent
    Web Services
    Library's
    Component's
    Applications
    Articles
  Flash streaming servers  Flash button as Flex icon  Flex form by email  Hello Remoting with AS3  AS3 Saving data from Flash  AS3 Loading data into Flash  Fire Effect  Contact form  Dragable buttons  Hello World with openamf  Loading helper classes  Upload with Flash 8  Transitions effects  Snapshot with Flash 8  Hello World Remoting AS2  Flash AS2 Remoting Connector  Saving data from Flash  Loading data into Flash  FlashCom & Remoting login  Cell Renderer API  Editing a table using remoting components  Flash MX2004 web service classes  Browsing a catalog  amfphp Documentation  Hello World Remoting  Online Store with AMFPHP  Flash clients for Web Services  Web Service Walk Though with NuSoap  Popup windows in flash with javascript  Installing Apache/PHP  MoreOver News Feeds  Load Edit Save Text Files via CGI  Save Movie Clip Postion via PHP and MySQL
Current Page (1) Next Page >>  View Article Example >> 1 | 2 | 3 | 4 | 5

Installing Flash Remoting for PHP (aka amfphp)

First install the Flash remoting components. The components include the classes you need to connect to Flash remoting, and also debugging and formatting classes that will help out when developing.

Next download the current version of AMFPHP from http://www.amfphp.org/. We will try to update this tutorial as the AMFPHP project matures. For this tutorial we will be working in a Windows environments and Mac OS's (there's not much difference).

After you have downloaded the current version of AMFPHP unzip them and take a look at the files. You will see three folders: amf-core, browser and services. The most important is amf-core, where the core library resides. In the app folder, there is a file called Gateway.php. This file builds the communication between the application and the amfphp library, we need to correctly point to it in order to work with the complete services. This path is the most important consideration that we need to keep in mind when building our service. The service should have: a gateway php that points to the amf-core/app/Gateway.php and a baseclass pointer to our service.Our service could be anywhere as far as the gateway knows the path, but the usual practice is to leave in services folder inside amfphp installation or in a services folder inside our own application. Here's a minimal gateway in version 1.2 (full version with the explanation of all parameters is included in amfphp main folder):

<?php
    
include "../amfphp/amf-core/app/Gateway.php";
    
    
//You can set this constant appropriately to disable traces and debugging headers
    //You will also have the constant available in your classes, for changing
    //the mysql server info for example
    
define("PRODUCTION_SERVER"false);

    
$gateway = new Gateway();
    
    
//Set where the services classes are loaded from, *with trailing slash*
    
$gateway->setBaseClassPath("./services/");
    
    
//Loose mode means echo'ing or whitespace in your file won't make AMFPHP choke
    
$gateway->setLooseMode(true);
    
    
//Read above large note for explanation of charset handling
    //The main contributor (Patrick Mineault) is French, 
    //so don't be afraid if he forgot to turn off iconv by default!
    
$gateway->setCharsetHandler("utf8_decode""ISO-8859-1""ISO-8859-1");
    
    
//Error types that will be rooted to the NetConnection debugger
    
$gateway->setErrorHandling(E_ALL E_NOTICE);
    
  
    if(
PRODUCTION_SERVER)
    {
        
//Disable trace actions
        
$gateway->disableTrace();
        
        
//Disable debugging headers
        
$gateway->disableDebug();
        
        
//Disable Service description
        
$gateway->disableServiceDescription();
    }    
    
//Service now
    
$gateway->service() ?>

Note that here we left the setCharsetHandler to utf8, production server to false, so we can see possible errors and also set the error level. Important is to set the path to the amf-core/app/Gateway.php correctly at the beginning and also the setBaseClassPath method should point to the services folder you're using. Note that both path are relative to the place wher gateway.php is. You can use absolute path also, but then each time you move your application you should fix the path, specially if you don't use your service inside the amfphp library like we will do.

There are many new features in the last library, just let's point a few:

For our example we need to create a folder for our application (named Hello) on the same level as the amfphp folder. So in the first line, we go a step above to look for the amfphp folder (relative to this file). Then, we need to create a services folder inside our application folder (named Hello) to store all our own services and set it as the BaseClassPath for our service. But before moving to our folder structure, let's take a quick look at amfphp installation for Mac users

 

Current Page (1) Next Page >> 1 | 2 | 3 | 4 | 5