tags:

views:

51

answers:

3

I have this function in .net code:

public class StringGenerator
{
    public static string GenerateString(string hash)
    {
        return hash.GetHashCode();
    }
}

I want to be able to call this from PHP page. Any idea how?

Edit: looking in php documentation, http://www.php.net/manual/en/class.dotnet.php, I see that it possible. but I can't code the code to find this dll, even with strongly named dll. the dll file is in the same folder as the php page.

A: 
volody
Neither of those will help to call .NET functions from PHP.
Arda Xi
Why do you think so?
volody
Because Mono itself only runs C# and VB.NET, and Windows Azure is a cloud-hosting service. Neither have anything to do with PHP.
Arda Xi
With Mono is possible to create a simple asxh handler that will process GenerateString call, and then make a call this page from PHP. This can be done on same Linux server. With Azure that will be PHP to web service call or even simpler it can be same style ashx handler call.
volody
Now that, as an answer, would've actually provided help. I don't see that anywhere in the list of links, though.
Arda Xi
+2  A: 

If you're on Windows, this article might help:

PHP and .NET

On another platform you could possibly use something like Phalanger to get access to the .NET runtime through PHP.

Arda Xi
+1  A: 

There are several ways to include .NET DLLs in your PHP installation (already well-documented), most of which are quite complicated and tend to be more trouble than they're worth as you lock yourself into running IIS as your webserver.

The best solution is to write web services which you can deploy on an IIS server. This frees you from having .NET dependencies in your PHP code, making it infinitely easier to migrate your application to another environment should the need ever arise. Creating web services in Visual Studio is a breeze - just start a new web service project, drop in your DLLs and VS automatically generates a WSDL that you can hit with PHP's SOAP functionality.

I was in this same situation last year and I explored both options - web services were definitely the better and more flexible option.

Jarrod
I have a legacy functions in .net that I need to call from php. It's need to be fast, so I want to just use the exiting code. the target php site is on windows 7. in a migration situation we will port the code to php.
stacker