Storing classes in a PHP Session with AMFPHP

On October 6, 2008, PHP / HTML - 1 Comment

I’m working on a small project with a AMF / PHP backend. The project has different roles and users, and I’m storing the user object in the session of PHP.

Now, according to the PHP manual, it should be possible to store complex objects (and classes) in the session. So when I put the user in the session and then dumped the session to the browser, I was pleased to see everything was in it. So far so good…

But then, strange things started to happen. Whilst the data was in the session, I wasn’t able to get it out easily. To understand what I mean, look at the following examples:

The user has a property ‘projects’, which is an array of projectObjects, which look like this:

class ProjectObject {
	var $_explicitType = "ProjectObject";
 
	public $name;
	public $id;
	public $lastModified;
}

Pretty straightforward.
Now, when i output the projects array using print_r, I get this:

Array
(
    [0] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => ProjectObject
            [name] => Test1
            [id] => 1
            [lastModified] => 1218479521000
        )
    [1] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => ProjectObject
            [name] => Test
            [id] => 2
            [lastModified] => 1218479559000
        )
)

Which is ok (I think).
But when I want to access any of the properties of the project, it will return an error, null or an empty string:

echo $user -> projects[0] -> id; // returns "";
echo $user -> projects[0][id]; //Fatal error: Cannot use object of type _PHP_Incomplete_Class as array
echo $user -> projects[0]["id"];//Fatal error: Cannot use object of type _PHP_Incomplete_Class as array

Weird huh? more…

WebOrb closes the gap!

On May 7, 2008, Flash / Flex,php - 1 Comment

As of 30/04/2008, the Midnightcoders have released a new version of WebOrb for PHP (version 3.0.0). (Thanks David C. Moody for letting me know). And boy, they’ve certainly improved the performance!

In my previous post WebOrb was a factor 4 slower than it’s opponent, AMFPHP. With this new version, the difference is much smaller. I ran the ‘invoke large dataset’ test and the difference was only 40ms (It used to take 6 seconds, it now takes 270ms). So AMFPHP still holds the speed record, but WebOrb is closing in! more…

AMFPHP vs. WeborbPHP

On March 14, 2008, Flash / Flex,php - 8 Comments

The other day, we were discussing remoting frameworks and the options you have on a php server. At my work, we use AMFPHP, and never really looked for other solutions. For .NET applications we use WebOrb, so I was wondering how the php version of WebOrb would perform. The results are quite shocking.
more…