Mapping PHP and Flex Objects

半世苍凉 提交于 2019-12-12 13:29:53

问题


I am using ZendAMF for remoting.

<?php
    error_reporting(E_ALL | E_STRICT); //error reporting, not needed

    require_once "Zend/Amf/Server.php"; //the zendAMF server
    require_once "process.php";  //our test class

    $server = new Zend_Amf_Server(); //declare the server

    $server->setClass("process"); //load our test-class to the server
    $server->setClassMap("Session", "Session");
    echo($server->handle()); // needed to start the server
?>

My Question is i have a ActionScript class Session and a PHP Class Session, but still it does not get mapped. I have some doubts... may be silly...

Should the file name of PHP class to be the same name of class name, as its not necessary but while mapping does it carry a value score.

How will you call those mapped objects inside your flex application. My approach is indicated below, but not sure whether its correct or not.

$server->setClassMap("Session", "Session"); Which is a PHP and Flex class in the above function.

Also my PHP session class is inside the include directory, should i indicate that anywhere or the ZendAMf will take care of it.

Flex Code.

var userSession:Session = new Session();
sessionHold.text = userSession.userid; 

Thanks.


回答1:


There's a few different things that you need to do. Usually it's something like adding the

[RemoteClass(alias="Session")]

to the metadata of your AS class or using one of Zend_Amf's functions like getASClassName() in your PHP object. Check out Wade Arnold's (writer of Zend_Amf) screencast re: class mapping. I'm sure he'll have your answer.

http://www.wadearnold.com/tutorials/zend/classmap/




回答2:


TypeOneError is correct; you're going to need

[RemoteClass(alias="Session")]
[Bindable]

at the top of your ActionScript classes.

A few other things that I've determined can cause this issue:

  • Class variables must be public and have identical names
  • The ActionScript class should not have a defined constructor


来源:https://stackoverflow.com/questions/1032283/mapping-php-and-flex-objects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!