Hi all,

I've finally gotten around to add AMF3 support to amfphp, so you can 
finally use Flex 2's RemoteObject with it. To test the new features, 
I've created a new Service Browser in Flex 2 which allows you to 
introspect services and test methods on the fly. I need people to test 
out the new AMF3 support.

New/changed features:

- $this->methodTable is DEAD. All methods in /services are now 
considered remotely accessible, unless you set them to protected or 
private (PHP5) or start the method name with an (_), in which case it 
will throw an error. If you want to get a description of a method and 
it's arguments without looking at the class itself, add JavaDoc to the 
method and you should see it in the new Service Browser.
- _authenticate is dead, as a side-effect of the removal of the 
methodTable. You can secure methods by creating a special function 
called "beforeFilter($methodName)" in your class and return false to 
stop a method from being executed. (the _ and the beforeFilter are the 
conventions used by CakePHP, so I figured I'd use those instead of 
rolling my own).
- Circular references in AMF0 and AMF3 should now work. Class mapping 
code has been ported to the AMF3 code also. To use remote class mapping, 
use registerClassAlias or the [RemoteClass] metadata tag, then read the 
instructions in advancedsettings.php
- Returning a mysql_query will now return either an Array or an 
ArrayCollection depending on the setting in gateway.php. Other database 
types are currently unsupported in AMF3 mode (they will be supported as 
soon as I am sure the AMF3 code is perfect).
- You can send ByteArray, ArrayCollection and ObjectProxy instances as 
arguments to remote methods. You will receive the result as a string, as 
the inner array and as the inner object, respectively. Currently there 
is no way to send back these types to Flash, but there will be in the 
next version.
- /browser now brings up the brand spanking new Flex 2-based service 
browser. You can test methods directly through it. If the method returns 
an array or arraycollection, the browser will attempt to show it in a 
datagrid (sweet). Please feel free to modify servicebrowser.mxml (it's 
very spaghetti-code-ish, but it works). You will need the Adobe corelib 
to compile (google for the link)

Limitations/things to keep in mind:

- MySql works but not other databases
- You can use a JSON string for arguments in the service browser. 
However you must wrap object keys in quotes (a limitation of Adobe corelib).
- Paged recordsets don't work anymore
- Only tested in PHP5. PHP4 might show issues with circular references.
- Calling two methods on a remoteObject one after the other (during the 
same frame) might not work.
- Charles and ServiceCapture have some issues with AMF3 handling. You 
might see strings which seem out of place in your output while it works 
fine in Flash. I will notify the people involved. You might want to set 
PRODUCTION_SERVER to true in gateway.php if this is a recurrent problem, 
in the meantime.
- If you need to send to Flash a class and want it to be mapped to a 
class in a package, you need to add a key to the class called 
_explicitType with a value of "com.mypackage.TheClass" and use 
registerClassAlias or [RemoteClass] as usual ( a limitation of php not 
supporting packages)

All that being said, I need testers. Please download it here:

http://5etdemi.com/uploads/amfphp-1.9.alpha.zip

(although it states it is amfphp 1.9, there will be no amfphp 1.9. 
amfphp 2.0 will be amfphp 1.9 + JSON and possibly XML-RPC)

If you run into any issues, please either:

- Create a minimal test case which shows the reproducible bug, then send 
it to me.
- In gateway.php, uncomment $gateway->logIncomingMessages and 
logOutgoingMessages, create an in and an out folder and run it again. 
Then send the log files (*.amf) to me.

Please send the feedback to pm AT 5etdemi DOT com. I am confident it 
should be pretty stable, as most of the new code is lifted from 
Fluorine, but you never know. Once I am 100% sure the amf 3 code is 
bulletproof I will release another version with some publicity on the 
blog and the homepage (currently keeping the new code low-profile).

Thanks,

Patrick

Reply via email to