SabreAMF 0.6 -> upgrade recommended

Edwin Koster found a pretty big bug in AMF3 deserializing, which was actually also identified by Patrick Mineault right before my vacation.. Thanks for those bug reports!

That one's fixed now.. It was related to AMF3 object deserialization. For the people using SabreAMF for their flex projects: Upgrading is highly recommended!

IExternalized and ArrayCollection

Additionally, I added IExternalized-object support. What most likely the biggest change is for people, is that the ArrayCollection object now arrives differently. Before it would have been an anonymous object with the 'source' property containing the data, now there's an actualy php equivalent for the ArrayCollection object, namely SabreAMF_ArrayCollection.

If you want to see how it works, I'd recommend simply checking out the source.

For people who don't know PHP5's SPL objects too well, the ArrayCollection implements IteratorAggregate, Countable and ArrayAccess.. in practice this means you can do most general Array operations on this object..


  $data = array();
  $data[] = array('property1'=>'yo','property2'=>'test2');
  $data[] = array('property1'=>'foo','property2'=>'bar');

  $arrayCollection = new SabreAMF_ArrayCollection($data);

  foreach($arrayCollection as $row) {

     // So yea, you can just loop through it like a normal array (done through IteratorAggregate)


  // Or get values straight from a certain row (done through ArrayAccess)

  // Or get the total number of rows (done through countable)


  // In the case you need a normal array, based on the ArrayAccess class

  $normalArray = iterator_to_array($arrayCollection);


If you want to check out how to create your own externalized objects.. (remember this always has to go paired; create one in flex, and create one in php), base your class on the SabreAMF_Externalized interface.

Also, be sure to let me know if there are any other well known flex classes that could really use SabreAMF equivalents..

The only other change is, that if exceptions don't provide a value for the 'code' property, the classname is passed by default.


As usual you can upgrade using:

pear upgrade

Or do a fresh install with:

pear install

Mailing list

I'd also like to point out that there's a mailing list do drop your questions.. The response might be quicker than the comment box..

Subscribe at osflash