AMFPHP Deserializer and POG classes

Posted on March 21, 2008 | 2 comments

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:

// $mappedClass = SomeObject
$mappedClass . “php” // SomeObject.php
// or
$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:


elseif(file_exists($GLOBALS['amfphp']['customMappingsPath'] . ‘class.’ . strtolower($mappedClass) . ‘.php’))
$include = $GLOBALS['amfphp']['customMappingsPath'] . ‘class.’ . strtolower($mappedClass) . ‘.php’;

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

  • jwopitz

    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.


  • Pingback: tutorial: Flex + AMFPHP + POG « explorers’ club

  • Renaun Erickson

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