3 Replies Latest reply on Feb 17, 2010 8:19 AM by msakrejda

    echo versus AMF

    hidarikani Level 2

      Which way of sending XML documents from PHP to Flex app is better and why:


      1. convert the XML document into PHP's DomDocument object and send it over AMF (with the help of Zend_Amf)

      2. echo the XML document

        • 1. Re: echo versus AMF
          archemedia Level 4

          By far the first one! amf serializes your data, which is MUCH faster!


          If your data comes from a database, then you shouldn't even convert it to xml but use plain objects.


          See the vo (value object) or dto (data transfer object) design patterns



          1 person found this helpful
          • 2. Re: echo versus AMF
            hidarikani Level 2

            I have to read XML files from the file system.

            Is the serialized DomDocument object really smaller that the echoed XML file?

            • 3. Re: echo versus AMF
              msakrejda Level 4

              It depends on the XML file. It'd be hard to beat '</>', which (barring the preamble) is a valid XML document. However, XML is very repetitive: e.g., in a simple structure like <items><item>an item</item><item>another item</item>...</items>, you'll have the strings '<item>' and '</item>' repeated potentially hundreds of times. AMF avoids this (although I'm not sure to what extent that is true when sending XML over AMF). If your documents are small and there are few of them, it probably doesn't matter. If your documents are large or there are lots of them, I'd do some ballpark performance testing for your use case.

              1 person found this helpful