AMFPHP Deserializer and POG classes

March 21st, 2008

The default AMFPHP patterns for including classes defined in your AMF requests do not work for POG classes. The two default patterns that are check for class including by the AMF deserializer are:

PHP:
  1. // $mappedClass = SomeObject
  2. $mappedClass . "php" // SomeObject.php
  3. // or
  4. $mappedClass . ".class.php" //SomeObject.class.php

For POG classes the pattern is "class.someobject.php", regardless of the case of the SomeObject class.

Now to added different locations for AMFPHP to look for classes to include for deserialization of AMF requests you open up /amfphp/core/amf/io/AMFBaseDeserializer.php. Go to line 384 (as of AMFPHP 1.9 or the block of code starting with file_exists($GLOBALS['amfphp']['customMappingsPath']) and add the following code for POG classes pattern:

PHP:
  1. elseif(file_exists($GLOBALS['amfphp']['customMappingsPath'] . 'class.' . strtolower($mappedClass) . '.php'))
  2. {
  3.     $include = $GLOBALS['amfphp']['customMappingsPath'] . 'class.' . strtolower($mappedClass) . '.php';
  4. }

Now your AMF request classes passed in method parameters will be deserialized on the PHP to the correct POG class.

Entry Filed under: Adobe Flex, Flex,AMF,PHP, Rich Internet Applications

3 Comments Add your own

  • 1. jwopitz  |  2008-03-21 at 6.53 am

    Yeah, as a PHP noob, I don’t think I would ever have been able to solve this on my own. Thanks again for the help. I will link off this as well as get the POG guys to link to this article.

    So I am curious tho. If I were to simply change the name of the POG object file from class.somename.php to SomeName.php, I wonder if that would’ve worked. I am not sure what dependencies POG has on the file names.

    A good question to ask ol’ Joel Wan at POG.

    Thanks,
    jwopitz

  • 2. tutorial: Flex + AMFPHP +&hellip  |  2008-03-21 at 7.07 am

    [...] Since initially this tutorial only happened to touch upon the setup of these technologies there hadn’t been any issues encountered. Obviously this tutorial didn’t reflect a real implementation of such a setup beyond the simple Get method. Further development has turned up an interesting find about sending AS3 objects out from Flex to be mapped to a POG object. As it is now, it can’t. That is because the naming convention chosen by the POG framework doesn’t get picked up by the AMFPHP deserializer. My gunslinger buddy Renaun Erickson has found a simple solution for this that doesn’t break the POG naming convention. You can read more about it on his blog - link. [...]

  • 3. Renaun Erickson  |  2008-03-21 at 10.59 am

    @jwopitz If you would change the name to SomeObject.php instead of class.someobject.php it should work correctly with the default AMFPHP install.

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


About: I work as a Platform Evangelist for Adobe Systems Incorporated.

My Amazon.com Wish List

Calendar

March 2008
S M T W T F S
« Feb   May »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Most Recent Posts


Flex.org - The Directory for Flex