1 / 3
Caption Text
2 / 3
Caption Two
3 / 3
Caption Three margin testing

Saturday, May 23, 2009

Install AMFPHP on GoDaddy Hosting Site

I got all my information form the following 3 web pages, especially the first one:
1. Install the AMFPHP

First download the AMFPHP library, unzip it and then copy the amfphp folder to webserver. On my Linux hosting site this folder is
~/html/Sites/en.h.com/amfphp
and the URL is http://en.hycademy.com/amfphp. (delete the .htaccess file from this folder.) If everything is right, you will be able to test all the exposed PHP classes at: http://en.hycademy.com/amfphp/gateway.php

Then download StartingWithAMFPHP1.zip Use SQL script to generate tables in MySQL database. Extract all from PHP directory into AMFPHP service directory. In FLEX directory you can find a finished Flex project that you can import into your Flex workspace.

2. Create database

mysql -h dbname.dbhost.com -u username -p <amfphp.sql

3. Create PHP files
PHP service classes
~/Sites/en.h.com/amfphp/services/org/zgflex/cookbook/services/FlexAMFPHP.php
~/Sites/en.h.com/amfphp/services/org/zgflex/cookbook/services/SoccerManager.php
data objects
~/Sites/en.h.com/amfphp/services/org/zgflex/cookbook/dao/Player.php
~/Sites/en.h.com/amfphp/services/org/zgflex/cookbook/dao/Team.php

Please note, PHP script must have the same name as the class inside of it.

4. Create Flex project
Import the Flex project.

MXML application uses two remote objects, one is calling dummy PHP service and the other one works with the soccer data and helps you handle the data.

StartingWithAMFPHP.mxml

......

<mx:RemoteObject id="FlexAMFPHPService" source="org.zgflex.cookbook.services.FlexAMFPHP" destination="amfphp"
fault="faultHandler(event)" showBusyCursor="true">
<mx:method name="communicationTest" result="checkCommunicationHandler(event)" />
<mx:method name="checkAnotherMethod" result="checkCommunicationHandler(event)" />
</mx:RemoteObject>

<mx:RemoteObject id="SoccerService" source="org.zgflex.cookbook.services.SoccerManager" destination="amfphp"
fault="faultHandler(event)" showBusyCursor="true">
<mx:method name="getTeams" result="getTeamsHandler(event)" fault="faultHandler(event)" />
<mx:method name="updateTeam" result="updatedTeamHandler(event)" fault="faultHandler(event)" />
</mx:RemoteObject>

......

Just as you created PHP data class in Team.php, you need to create a simple mapping class in Actionscript. In this class you will store all the data and use it for handling data changes and sending the data back to the server. See Player.as and Team.as in Flex project folder: src/org/zgflex

You also need to configure services-config.xml file, and edit your URL to the AMFPHP gateway.php script.You have to use this XML file while the Flex project is compiled. You will do this by adding compiler parameter in project properties. Your compiler propetries should look something like this:

-locale en_US -services "services-config.xml"

Export the release build to bin-release folder and upload it to webserver's folder: ~/html/Sites/en.h.com/StartingWithAMFPHP/, and now you can access it at: http://en.hycademy.com/StartingWithAMFPHP/StartingWithAMFPHP.html

No comments:

Post a Comment

Featured Post

Windows和Ubuntu双系统完全独立的安装方法

http://www.ubuntuhome.com/windows-and-ubuntu-install.html  | Ubuntu Home Posted by Snow on 2012/06/25 安装Windows和Ubuntu双系统时,很多人喜欢先安装windows,然...