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.

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

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.
0

4 Comments

Neither of those will help to call .NET functions from PHP.
Because Mono itself only runs C# and VB.NET, and Windows Azure is a cloud-hosting service. Neither have anything to do with PHP.
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.
Now that, as an answer, would've actually provided help. I don't see that anywhere in the list of links, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.