Mapping PHP and Flex Objects

2019-07-13 10:21发布

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.

2条回答
够拽才男人
2楼-- · 2019-07-13 10:54

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
查看更多
我只想做你的唯一
3楼-- · 2019-07-13 10:55

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/

查看更多
登录 后发表回答