Installing amfphp on IIS
Posted
Sunday, June 12, 2005 4:14 AM
by
Shunjie
I have been using Flash remoting with .NET for quite some time already,
nearly a year if I am not wrong, from the time whereby we have to
include NetConnection.as inside our scripts to now whereby we simply
import from the mx package within the AS2.0 classes. Experience with it
is rather smooth sailing, as the installation is sort of "fool-proof"
(with installer) and for the starter , all the codes snippets provided
in the included examples simply works when being cut and pasted into
another context. Due to work requirement, I have to interop Flash with
PHP at times. In the past, the model is simple, need a simple string
from PHP ? Use loadvars object. Need to get structured data from PHP?
Use XML. But I think its good to pick up new things @ times so today, I
decided to test out
amfphp to try out Flash remoting with PHP
AMFPHP is an open sourced Flash remoting for PHP. The current Flash
remoting component Macromedia provides allow us to work with .NET,
coldfusion, and J2EE. Within these 3, I had worked with .NET
extensively, and a bit on with coldfusion. Installing AMFPHP while
following
the steps
on the site resulted in..erhm..error.. I think there is no problem with
the instructions but its just that I am still not very familiar at how
the framework works. So after googling for a while, I
finally got the answer. So I thought it will be good if I list down the
steps here. I think there is quite a few articles too on
actionscript.org
which touch on the same thing too, but I am going to be more IIS specific. In the steps below, I am going to assume you have
installed PHP on IIS (which I do) Alright, here's how:
1) Download the zipped file from
amfphp
2) Unzip the folder
3) Once you open the folder, you will see folder named 'source', inside containing 'docs', 'examples', and 'flash services'
4) If you have used Macromedia Flash remoting before, installing it
will add an 'flashremoting' directory to your wwwroot folder.
Ok, the 'flash services' will actually serves the same functionality in
this case. So, you will need to copy it into the wwwroot folder. So
in most case, simply copy it into c:\inetpub\wwwroot\
5) Ok, its installed! Let's test if it is working
6) Now similar to Macromedia Flash remoting, you will need a gateway.
In Flash remoting for .NET, it is simply a page like default.aspx
residing in the virtual directory. A gateway will reside in the
web root folder in this case too.
7) We will use the example given. Now, navigate to the 'examples'
folder, and within it there is this 'basic' folder. Copy the basic
folder and place it inside the wwwroot folder again. So right now, you
will have 2 folder inside wwwroot. The 'basic' folder, and the
'flashservices' folder.
8) Inside the 'basic' folder which you have pasted inside the wwwroot
folder, you will see a file named 'gateway.php'. This is the gateway
file. Open it using any text editor, and you should be able to see
these lines:
include "flashservices/app/Gateway.php";
$gateway = new Gateway();
$gateway->setBaseClassPath("services/");
$gateway->service();
9) We need to nagivate to our 'flashservice' folder, so right now the
gateway.php is inside the 'basic' folder, and the 'flashservice' folder
is one level above it. So we simply, change it to
include "../flashservices/app/Gateway.php";
10) Next is the line $gateway->setBaseClassPath("services/")
One thing that confuse me at first is , is this path refering to the
'services' folder within 'flashservices' folder? Or is it refering to the
'services' folder within the 'basic' folder? Well, the path here is
relative to the folder your 'gateway.php' is residing. So 'gateway.php'
is inside 'basic' folder, and therefore this is the 'services' folder
within the 'basic' folder itself.
11) Next, open the credential.fla file located inside the 'basic' folder. You realize that it has this line
NetServices.setDefaultGatewayUrl("http://localhost/gateway.php");
In this case, we did not move gateway.php inside wwwroot folder, so we change it to
NetServices.setDefaultGatewayUrl("http://localhost/basic/gateway.php");
12) Now is all set up, simply run the file and you will see "Welcome administrator".
13) If you see something like "_Session not set", then you will need to do this.
Open php.ini file (should be located at C:\WINDOWS\php.ini)
Look for 'Error handling and logging'
If your setting is 'error_reporting = E_ALL; display all errors, warnings and notices',
then change it to
'error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR'
Thanks to
Flash Remoting: the Definitive guide for this solution
14) run the fla again, you should see 'hello administrator'
Well, once that done, everything should be working fine. =)
If you need to use AS2.0 class for AMFPHP, check out this article at community mx
http://www.communitymx.com/abstract.cfm?cid=B74BC