Search code examples
c#phpphalanger

Phalanger PhpObject always null


I want to use methods defined in PHP from C#. I used Phalanger to create a .dll from my PHP file (using pure mode) and added it as a reference in my project.

I can successfully call the dll, but the PhPObject I attempt to create is null, so I cannot pass it the correct parameters.

Here is the code I am running: https://i.sstatic.net/uQ41X.png

This is the example where I took the code to make the PhPObject: http://wiki.php-compiler.net/Code_Samples/Standard_mode_interoperability

I'm thinking Phalanger might not have installed correctly, but i'm not sure how to fix it since I do not get any errors, the object is just null.


Solution

  • ScriptContext does not see your C# references - you have to add configuration into your app.config with references to your PHP DLL.

    <phpNet><classLibrary><add assembly="xxx.dll" />
    

    Anyway, if you are compiling PHP code in pure mode, you don't have to use ScriptContext at all (thats the point of pure mode); just reference the DLL and use PHP classes in the same way as any other .NET class (no ScriptContext).