Class Not Found
2 posts
• Page 1 of 1
Class Not Found
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 :)
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
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
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 25 guests