Welcome, Guest. Please login or register.
Did you miss your activation email?
05/21/12, 03:10
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  Flash Remoting with AMF (Moderators: Flash-db, Musicman, Jorge Solis, papachan, nothingGrinder)
| | |-+  AMF and PHP5, Hello World Remoting
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 Print
Author Topic: AMF and PHP5, Hello World Remoting  (Read 8171 times)
Adam Schroeder
Server what's that
*
Posts: 14



View Profile WWW
« on: 11/16/04, 14:16 »

Currently I have the Hello World Remoting tutorial running with AMF using PHP 5.

I did not have to modify any code within AMF to get this to work.

From my internet searches I have read that parts of AMF are not compatible with PHP 5.

Frankly I didn't expect the Hello World Remoting to work without some modifications to the PHP code, but I suppose things may start to break when I begin creating more complex objects and variables to send back to flash.

I am very new to PHP, and currently am only using it to pull data from a SQlite database and perform minor type conversions.

I was thinking it may be a helpful if we put all the information need to get AMF working successfully with PHP5 in one location (such as this thread).


Here are some pieces I have found online, although I don’t fully understand how to implement them.

This deals with changing the RemotingService.php script:
http://sourceforge.net/mailarchive/message.php?msg_id=8907838

This deals with a naming conflict caused by “Exception.php”.  Solutions are to rework the Exception function or comment out the references to it.
http://sourceforge.net/mailarchive/forum.php?thread_id=5538137&forum_id=24803

Is there anything else that we need to fix to get it working correctly?  Does anyone have these changes already made?  We could find a place to host the files that need updating, or even create a whole new AMFPHP flash services zip file that includes all the necessary changes.

Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #1 on: 11/16/04, 16:07 »

Hi Adam, welcome to the Boards!

Is a good idea, but probably in this thread: http://www.flash-db.com/Board/index.php?board=24;action=display;threadid=5601 that deals with common problems.

The main problem with PHP5 is around the Exception handler (now a build-in handler to manage exceptions) The other problem was addressed in posted thread.

Jorge
Logged

Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #2 on: 11/16/04, 16:19 »

Hello Adam,
welcome to the boards.

If youre environment is exactly like the one in the sample, the sample will run.
It looks like you have done exactly this Wink

But, if you want to do more complex things, it is important to go step by step, and in turn understand these steps.

Next step could be the "ParkService", which leads you deepr into AMFPHP.
If you understand how ParkService works, you are ready to do your own service classes.
Logged

happy flashing
Cool
Ronald
Adam Schroeder
Server what's that
*
Posts: 14



View Profile WWW
« Reply #3 on: 11/16/04, 17:22 »


Is a good idea, but probably in this thread: http://www.flash-db.com/Board/index.php?board=24;action=display;threadid=5601 that deals with common problems.
Jorge

Thanks for the welcome Jorge!

I thought a separate thread dealing with getting AMF to work with PHP5 would be nice (obviously),  but if you want to wrap it into your other thread and delete this one that is fine with me.

Can I ask some more detail on how to implement the changes to the RemotingService.php?
Do I simply replace the entire script (what is the between the quotes) with the new code.  Starting with "call_user_func_array" and ending with "$this->__construct(); }"?

Does anyone have the work around created for the Exceptions object?


Ron,

Thanks for the welcome!

Definitely... I don't even begin to understand how the remoting works yet.   But it is much easier to start learning when I have WORKING base to experiment from.  Thank you very much for providing it!

I would like to get all the PHP5 incompatibles resolved so they don't crop up while I am trying to learn new things.  I'd like to avoid spending a lot of time troubleshooting my code if the problem was caused by a PHP5 incompatibility.

All of my data is stored in an SQlite database that is used in another program we have,  so PHP5 native support for this is extremely valuable.  Currently I’m sending everything via name value pairs,  but I have over 400 lines of code in my DataLoader class just to parse and sort out what I’m using.  I think remoting will be a much better solution for this,  plus I want to learn it anyway.

This is a great website,  I’ve been following it for a while now.

Thanks for all of your help!



Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #4 on: 11/16/04, 17:53 »

Look about the Exception problem on this thread http://www.flash-db.com/Board/index.php?board=24;action=display;threadid=10244

Since the RemotingService.php is and "add" to describe services, but not really a core one, I didn't search much further, but you can do and let us know.

I prefer to put errors on posted thread because some errors are common to both PHP versions

Jorge
« Last Edit: 11/16/04, 17:57 by Jorge Solis » Logged

Adam Schroeder
Server what's that
*
Posts: 14



View Profile WWW
« Reply #5 on: 11/18/04, 12:59 »

Well I'm moving one step at a time.  I haven't tried correcting any of the AMFPHP for PHP v5 yet, but so far it is working for me.

I am working on the Park Service implementation now.  First I converted the MYSQL data into an SQLite database.  I find (in my beginner state) SQLite much easier to work with than mySQL and my  final project will be running on it anyways.

AMFPHP needs a recordset filter for each record type.  So I initially got an error because there was not an SQLite filter.  I copied the MYSQL filter, and changed a few lines to make it work as the SQLite filter.

If anyone else want this.  Create a file named "sqliteRecordSet.php" and place it within "flash services\sql" and use this code

Code:
<?php
// Modified mysqlRecordSet.php by changing the relevant 
// lines to work with an SQLite database  - AS

// original section of writeRecordSet method JC
// this makes it easy for developers edit results 
// with touching the more important parts of the PHP Gateway JC
// maybe use different methods to format recordset 
// different ways depending on something??? JC

class sqliteRecordSet
{
   var 
$initialData = array();
   var 
$columnNames = array();

   function 
sqliteRecordSet($d)
   {
      
// grab all of the rows
      
while ($line sqlite_fetch_array($dSQLITE_NUM)) {
         
// decode each value ready for encoding when it goes through serialization
         
foreach($line as $key => $value) {
            
$line[$key] = utf8_decode($value);
         }
         
// add each row to the initial data array
         
$this->initialData[] = $line;
      }   
      
// grab the number of fields
      
$fieldcount sqlite_num_fields($d);
      
// loop over all of the fields
      
for($i=0$i<$fieldcount$i++)   {
         
// decode each field name ready for encoding when it goes through serialization
         // and save each field name into the array
         
$this->columnNames[$i] = utf8_decode(sqlite_field_name($d$i));
      }
      
$this->numRows sqlite_num_rows($d);
   }
}
?>
« Last Edit: 11/18/04, 13:01 by Adam Schroeder » Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #6 on: 11/18/04, 15:21 »

Thanks for sharing this. I recomend to pass also to the amfphp  developper list (you can subscribe in the Sourceforge amfphp page)
SQLLite is fine for little projects, but it's basically a text file, so be carefull if you need heavy work.
Post your class also in the Technical reference Board.

Jorge

Logged

Adam Schroeder
Server what's that
*
Posts: 14



View Profile WWW
« Reply #7 on: 11/18/04, 15:40 »

Done, and Done.  Smiley

99% of the access to the SQLite DB will be read only,  but thanks for the warning.  I will keep an eye out for problems if the project is scaled up.

Adam
« Last Edit: 11/18/04, 15:41 by Adam Schroeder » Logged
Adam Schroeder
Server what's that
*
Posts: 14



View Profile WWW
« Reply #8 on: 11/19/04, 10:56 »

Are there any code examples showing how to create objects within PHP and sending them to Flash?  My knowledge of PHP is... lacking.

I was able to pass objects using the MakeEcho in the Hello World Remoting example,  now I just need to know how to create them within PHP.

I have a basic AMFPHP working,  mirroring the simplest calls of the ParkService example.  But I used the Hello World Class as my starting point.  A component drop down box  (that adds a freaking 50K to my filesize) is populated by a record set returned from SQLite,  and the select triggers another database querry to get the details.


http://www.evilfree.com/evilAMFPHP/
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #9 on: 11/19/04, 12:09 »

To return objects use PHP arrays with keys

$myData = array(Nombre=>"Jorge", Otro=>"Pepe");
return $myData;

Jorge
Logged

Adam Schroeder
Server what's that
*
Posts: 14



View Profile WWW
« Reply #10 on: 11/19/04, 12:31 »

Ok cool!  That is easy enough.  I assume you can nest them as well?

Is it possible to return an object with functions, or a function by itself?  Or would you have to rebuild it from strings (or other data)  within flash?


Something like:
Code:
private function getBallAnimation_onResult(res:ResultEvent):Void{
    ball_mc.onEnterFrame = res.result;
}


or

Code:
private function getEmpoweredObject_onResult(res:ResultEvent):Void{
    var myObject:Object;
    myObject=res.result;
    myObject.takeOverTheWorld();
}


Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14600


View Profile
« Reply #11 on: 11/19/04, 12:40 »

Seems an overuse of Remoting, why call the server to ask for something that can be solved in client side? If you need to choice one or another function based on some data accesible on server, then return a variable to Flash and build an if (or switch) structure in Flash.

Jorge

Logged

Adam Schroeder
Server what's that
*
Posts: 14



View Profile WWW
« Reply #12 on: 11/19/04, 13:36 »

It was more of a what is possible question.

But, actually I do have a situation where it would come in handy.

We have many different projects that are all similar to each other,  but they have different data and different layout placements.  They are all built with the exact same Flash code, but run off of different data sources.

Some projects need to have custom items that are not shared among any others.

Ideally when I am finished I would like to have a single SWF file that handles all projects and everything else that is necassary after receiving the data source to use.  I don't want to recompile the SWF everytime I get a new type of "object" to add to a specific presentation.

If I could create a generic attach Movie clip function in my main program, and then pull completely built objects from remoting I would be able to accomplish most situations that might come up.

From a simple, static text field, or picture that stays constant through an entire presentation  to building a little Airplane that follow the users cursor could be accomplished with this method.

I know I could also also accomplish this using external SWF files,  I just want to know what options are available to me.

A little off topic:
If I were to use external SWF files,  what would be the best way to give them access to the classes that exist in my main movie?  Do I need to resort to a _global declaration, or _root access?  Or is there a cleaner way.
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #13 on: 11/19/04, 13:50 »

Hi Adam,
if you make a larger project, you have to deal with several movieclips anyway.
You will have for instance a base movie with the functions and classes, and the basich background images, and then you can load other movieclips with the loadMovie methode, and position, scale, rotate them via values read from a database.

You can mange the movieclips, you are loading, by data too.

The granularity of clips depends very much on your application, but take in count, that response is better for the user, as smaller the objects are, which have wo be loaded later.

A user is rather willing to hav multiple downloads of a few milliseconds, than waiting for minutes until he can see something.
Logged

happy flashing
Cool
Ronald
Adam Schroeder
Server what's that
*
Posts: 14



View Profile WWW
« Reply #14 on: 11/19/04, 14:04 »

Thanks Ron,

I understand that.  The base SWF file will be around 35K  (about half for the embedd font, and the other half is scripts).  The only thing in my .fla file is font, a loading message, and a call to my class.

All of the content (background, pictures, text, ect...) is loaded dynamically into empty movie clips.

Check out http://www.lexusedapt.com for the current version that is using Name Value pairs with LoadVars to get the data.  


Does AMFPHP have the capability to pass back functions, or objects with functions?  
Logged
Pages: [1] 2 Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything