I spent a day or two pulling my hair out and wondering if AMFPHP should be considered abandon-ware (no). I could get data to go back-and-forth. That part was pretty easy. But I wanted to pass a custom configuration object to the server as part of my request and couldn’t get any further than it showing up in PHP as an anonymous array.
I gave up, installed the Zend framework (which now includes an AMF implementation), and had similar (although slightly different) issues. After resorting to Charles to figure out what might be going wrong, I found the problem in my remote service class. It turns out my PHP chops were coming up short.
There are a bunch of AMF examples and tutorials out there, and I feel like I looked at most of them ; ) Very few talk about sending custom-classed parameters to the server. Instead, they show you how to pass numbers and strings (if anything at all). The best of these test-your-gateway examples have you send your parameter object to the server as an array. In php, you’d access those (array) properties like this: $config[‘myParam’].
However, if you’ve got mapping between Actionscript and PHP classes properly configured, that syntax isn’t going to work. Actionscript lets you access an object’s child properties via either ‘dot syntax’ or ‘array syntax’, but PHP is more picky.
Once you get your custom class mapping working, you need to access (class) properties like this: $config->myParam. Simple to be sure.
So, I thought I’d tried this (and every other syntax combination), but apparently not while I had the class mapping setup correctly. PHP errors in your AMF service class can be notoriously hard to debug. Most of the time when something went wrong with mine, I simply never got a response. But, once I fixed my service class, I could use either Zend or AMFPHP. Rock on.