AmfPHP tries wherever possible to convert an AMF object to its PHP equivalent. However there are types where this equivalence doesn’t exist. In such cases you’ll have to use special amfPHP classes that you’ll find in Amfphp/Core/Types.
Note that you can’t return a PHP resource directly, you have to convert it to an array!
Here is a summary of the cases and types:
- Undefined. AMF has an Undefined type. There is however not such a type in PHP. So an AMF Undefined is converted to a Amfphp_Core_Amf_Types_Undefined, and you must use this same class to send back an Undefined.
- ByteArray. AMF has a ByteArray type. There is however not such a type in PHP. So an AMF ByteArray is converted to a Amfphp_Core_Amf_Types_ByteArray, and you must use this same class to send back an ByteArray.
- Date. AMF has a Date type, which contains a timestamp. PHP has a DateTime type, but it is for PHP 5.2 and more, and the timestamp functionality is for PHP 5.3 and more. So for the time being an AMF date is converted to and from an Amfphp_Core_Amf_Types_Date.
- XML. AMF has 2 XML types: XML and XMLDocument. PHP has many XML types and serializers and deserializers. So rather than to try to mix and match, the choice is left to the user. AmfPHP will convert an AMF XML object to and from Amfphp_Core_Amf_Types_Xml, and a XMLDocument to and from Amfphp_Core_Amf_Types_XmlDocument. These classes both contain the XML data on the “data” property in string form, so the user can convert the data using whichever XML tools suits his purposes.
- Flex Array Collection. If you really need to send an Array Collection from Flex, you can. It will be received as an anonymous object in amfPHP, and the array with the data will be in the property _externalizedData. AmfPHP does not however support sending an ArrayCollection to the client.