Class Not Found

Discussion about the open-source Phalanger [?] project.

Class Not Found

Postby japatchett@codeplex » August 25th, 2007, 9:34 am

I'm trying to compile some class libraries I've written in PHP but having a problem with one part where it loads some plugins. All it needs to do is instantiate the class based on the name.

I've quickly written a spike to reproduce the problem :

<?

import namespace TEST;

namespace TEST
{

class hellotest
{
function hello()
{
return "hello world";
}
}

Export
class Library
{
function hello()
{
$hi='hellotest';

$e=new $hi();
return $e->hello();
}
}


}
?>

The class "Library" is then instantiated in a C# windows application where it calls the "hello" method and displays the result in a text box.

If I hardcode the class name i.e. $e=new hellotest(); everything is fine, but when trying to do it dynamically I getClass 'hellotest' Not Found. I've tinkered with the namespaces, with, without, using TEST:::hellotest etc... but everything give the same error.

I also attempted to use eval : eval('$e=new hellotest();'); but it gives the same error whether hardcoded in the eval string or built dynamically.

without this working my forray into Phalanger comes to an end, which would be a shame as I jumped for joy last night on discovering it - a truely awsome project :)
japatchett@codeplex
 
Posts: 2
Joined: January 7th, 2012, 8:55 pm

RE: Class Not Found

Postby japatchett@codeplex » August 25th, 2007, 10:46 am

Having browsed through the issues database looks like this is a bug. For me, since only myself and my small development team are the people writing plugins I'm just going to create a classresolver class in a seperate assembly that maps the string to hardcoded instantiations. Not ideal, but worth the hack to be able to use the Phalanger.
japatchett@codeplex
 
Posts: 2
Joined: January 7th, 2012, 8:55 pm


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 25 guests

cron

User Control Panel

Login

Who is online

In total there are 25 users online :: 0 registered, 0 hidden and 25 guests (based on users active over the past 5 minutes)
Most users ever online was 511 on April 27th, 2024, 10:11 pm

Users browsing this forum: No registered users and 25 guests