Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6767081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:54:31+00:00 2026-05-26T14:54:31+00:00

Yesterday, I succeeded in sending typed objects from a PHP application to a flex

  • 0

Yesterday, I succeeded in sending typed objects from a PHP application to a flex front-end using Zend_AMF as per this question.

The problem I am facing now is that I would like to send a typed object from flex to PHP and on the PHP side, be able to recieve it as a typed object instead of stdClass.

Here is the class in flex:

package com.mysite
{
    [Bindable]
    [RemoteClass(alias="CTest")]
    public class CTest
    {

        public var stuff1:String;

        public var stuff2:String;

        public function CTest()
        {
        }
    }
}

And this is the corresponding class in PHP:

<?php
namespace modules\testing;

class CTest{

    var $_explicitType = 'CTest';

    var $stuff1;

    var $stuff2;
}

In flex, I am sending the object like so:

var remoteObject:RemoteObject = new RemoteObject(); 
remoteObject.endpoint = "http://localhost/to/my/amf/endpoint"; 
remoteObject.showBusyCursor = true; 
remoteObject.source = 'testing'; 
var op:AbstractOperation = remoteObject.getOperation(null); 
op.addEventListener(ResultEvent.RESULT, result); 
op.send( new CTest()); 

On the PHP side, the object is retrieved into a variable called $parameters. I then use print_r on it to write the result to a file:

$z = print_r($parameters, true);
$s = fopen('D:\test.txt', 'w+');
fwrite($s, $z);
fclose($s);

And as can be seen, the result comes back untyped and is a stdClass object:]

Array
(
    [0] => stdClass Object
        (
            [stuff1] => 
            [stuff2] => 
        )

)

After some testing, I removed the namespace from the PHP object and moved it into the global namespace. This seems to have resolved the issue. I have tried setting RemoteClass to \modules\testing\CTest and also modules.testing.CTest. $_eplicitType was then set to the same value for both tests.

The result is that when I use modules.testing.CTest, this is the classname that Zend_AMF sees. If I use namespace notation, Zend_AMF sees modulestestingCTest, as all the slashes get stripped out.

But how can I get this working with php namespaces?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:54:32+00:00Added an answer on May 26, 2026 at 2:54 pm

    Finally resolved the issue. Here is the solution for those who might come across the same issue in the future.

    For your PHP class:

    <?php
    namespace app\testing;
    class CTest{
    
        var $_explicitType = 'app\testing\CTest';
    
        var $stuff1;
    
        var $stuff2;
    }
    

    For your actionscript class:

    package com.mysite
    {
        [Bindable]
        [RemoteClass(alias="app\\\\testing\\\\CTest")]
        public class CTest
        {
    
            public var stuff1:String;
    
            public var stuff2:String;
    
            public function CTest()
            {
            }
        }
    }
    

    I think the problem is due to the serialization and deserialization of the AMF body. Effectively, the remote class is has 2 slashes escaped, resulting in this: app\\testing\\CTest. Once it is deserialzed by Zend_AMF, since there are 2 slashes, it means that the backslashes are escaped into this: app\testing\CTest. This is just a hunch of course, but some testing with Charles proved that this is the case.

    Another possible solution is to modify Zend_Amf_Parse_TypeLoader.php. On line 99, we could replace:

     if(!$class) {
                $class = str_replace('.', '_', $className);
      }
    

    with

    if(!$class) {
         $class = str_replace('.', '\\', $className);
    }
    

    Effectively, we can then just use dot syntax for the class mappings, which actionscript will place nicely with:

    [RemoteClass(alias="app.testing.CTest")]
    
    var $_explicitType = 'app.testing.CTest';
    

    Obviously this will is a pretty nice solution, but I prefer not to modify with vendor code, as the Zend_AMF library will be updated with newer versions in the future. For now, my solution is to just use 4 slashes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

yesterday I've been using for the first time Swing for a quick desktop application
Yesterday, I asked this question and never really got an answer I was really
Yesterday, I discovered the Subversion (SVN) blame feature, and I was wondering, is this
Yesterday, I found myself writing code like this: SomeStruct getSomeStruct() { SomeStruct input; cin
Yesterday I got a call from a Microsoft representative asking if we supply hosted
Yesterday I found this function: function clone(obj) { return typeof obj === 'undefined' ?
Yesterday I was trying to implement a Listener for a SelectManyListbox using Ajax in
Yesterday, after about two years we re-deployed our application. Code hasn't changed, but the
Yesterday I added a custom MembershipProvider to an ASP.NET web application, but when I
Yesterday Oracle decided to take down java.sun.com for a while. This screwed things up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.