ZF-5885: $_explicitType Mapping not sending objects from Flex to PHP

Issue Type: Improvement Created: 2009-02-25T18:42:41.000+0000 Last Updated: 2010-01-22T06:16:52.000+0000 Status: Postponed Fix version(s): Reporter: Adeyemi Opanuga (yemixnuga) Assignee: Wade Arnold (wadearnold) Tags: - Zend_Amf

Related issues: Attachments:


Wade hi, I know this may sound impossible, but I have been working on a project using Zend_AMF and found out that when I use the $_explicitType method of class mapping in my project things become difficult. When using the $_explicitType method I get objects from PHP into Flex but when I try to send 1 object from Flex to PHP I get the channel diconnected error. I then switched to using the $server->setClassMap method and everything works fine. I have visited several blogs on this issue and no one has figured it out. I even found about 3 posts with similar problems in different blogs but no solution. I have continued building my application using the setClassMap method and each time I download an update (last tested 1.7.5) of the Zend_AMF I check to see if it would work but it's still not working. So please check this out. May be I am not doing something right. Thanks.

N.B - you can use Mihai's sample for a quick test : - just comment out the //$server->setClassMap("VOAuthor", "VOAuthor"); and add the public $_explicitType ='VOAuthor' and you would not be able to update data in the datagrid.


Posted by ionut stoica (iongion) on 2009-03-22T05:33:16.000+0000

After reading a whole lot about this "issue" i have discovered it is not such a trivial task.

Wade, you should check out SabreAMF and offer those features in Zend_AMF also.

They have a way of settings your own class mapping callback functions.

The issue with classmapping in php will and always be the loading/autoloading of classes, it is just the way php works. One sollutions will be to create a certain convention on class mapping, but this is limiting, the best way is leave it as it is and add support for overriding class maping through custom callback functions, just as SabreAMF does, please take a look, it will get you rid of a lot of problems and questions.

Posted by Wade Arnold (wadearnold) on 2009-03-24T12:40:58.000+0000

As you pointed out it is very difficult to de-serialize, instantiate the classmap class if it exists, and then populate it with data. I will check out what you spoke of and see what I can do to get something added for round trip with AS3 specifying the mapping. Really appreciate the suggestions, links, and general feedback.

Posted by ionut stoica (iongion) on 2009-03-24T14:12:40.000+0000

Sure, here they are:

SabreAMF wiki

The place that does all the magic:

SabreAMF_ClassMapper::$onGetLocalClass = 'flashToPHPClass'; SabreAMF_ClassMapper::$onGetRemoteClass = 'PHPToFlashClass';

where flashToPHPClass and PHPToFlashClass are simple custom php functions.

or :

SabreAMF_ClassMapper::$onGetLocalClass = array($classOrInstance, 'flashToPHPClass'); SabreAMF_ClassMapper::$onGetRemoteClass =array($classOrInstance, 'PHPToFlashClass');

as callbacks.


// actionscript [RemoteClass(alias="package.Stuf.Smuf.Zbuf")] class MyClass { }

// php class Stuf_Smuf_ZbufVO { }

if one wants a class mapping between those, the callback functions could look like: // (i did not include security): // neither i did not test it, but you get the idea

function flashToPHPClass($alias) { $parts = explode('.', $alias); unset($parts[0]); $phpClass = implode('_', $parts).VO; // now the $phpClass becomes: Stuf_Smuf_ZbufVO // that will either be loaded here (included,required) // or that will be autoloaded by the Zend_Autoloader return $phpClass; }

// so that it returns a class with "package" prefix and without the VO termination function PHPToFlashClass($class) { return 'package.'.substr($class, 0, -2); }

this can allow any naming convetion/class mapping system imagined.

look further on that wiki page and talk with "evertpot", he answers mails and cares about amf/php world on a different level, just like you. You should join forces :)

Posted by Wade Arnold (wadearnold) on 2009-04-22T12:01:43.000+0000

This is something be worked on for better mapping from Flex. Zend Amf is definitely PHP centric in regards to class mapping.

Posted by Andreas Adam (acadam71) on 2010-01-22T06:16:52.000+0000

Our Zend_Amf_Server has over 250 object types (classes). If we need to set the mappings via "$server->setClassMap" then we also have to import all php files with classes. The result is 250 "require_once"! And every new "require_once" in the server script makes the AMF server slower and slower... Better: the "$_explicitType" worked fine (in both directions) - then we can delete the 250 "require_once" and the 250 "$server->setClassMap" and the server will be faster!

Example: Access WITH "require_once" and "$server->setClassMap": 250 ms Access WITHOUT "require_once" and "$server->setClassMap": 25 ms

Result: the speed will be increased over 10 times!

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.