PureMVC Architects Lounge

PureMVC Manifold => Standard Version => Topic started by: toby869 on December 15, 2011, 02:32:40



Title: How to output amf as a viewcomponent?
Post by: toby869 on December 15, 2011, 02:32:40
I'm writing a basic API to some backend settings and I would like to return the results in different formats (xml, html, etc) for different frontends to consume.  How would I go about outputting amf?

I can think of three different routes (and none seem like they would be feasible)..

Wrap the facade within the services class...and somehow return data from the viewcomponents?

Create the gateway/services and pass that into the API to be used as a viewcomponent...and somehow still be able to access it properly as a remote object?

Something like this: http://efreedom.com/Question/1-1942890/Self-Contained-Library-Serializing-PHP-Data-AMF (http://efreedom.com/Question/1-1942890/Self-Contained-Library-Serializing-PHP-Data-AMF) where I basically have to format the amf output myself.


Any ideas greatly appreciated!


Title: Re: How to output amf as a viewcomponent?
Post by: toby869 on December 16, 2011, 07:28:44
After a lot more reading last night I realize this wasn't really a feasible question.  AMF isn't just a format, it's also how the messages are sent and received.  Technically, I could implement the serialization in the viewcomponent, but I would also have to address the RPC portion as well (like SOAP or REST).


Title: Re: How to output amf as a viewcomponent?
Post by: omar on January 05, 2012, 11:18:37
AMF is an encoding protocol to get PHP objects serialized for AS3 and vice versa. Ideally, you should create your PHP model classes so they return plain PHP objects with the data you need. For AMF you can then use the model class to get the PHP data objects and return them via AMF so they're serialized, fo XML  you could do the same and take the PHP data and translate it to XML before returning the XML output. Does that make sense?