Calling F # code (.Net dll) from php

I was wondering if you can name the F # code with php. Phalanger seems to be doing the trick. Does anyone use it? For these solutions and others (if they exist?), What requirements does it have on the server to run the code?

thanks

+4
source share
3 answers

Yes, you can use the PHP COM class , but it only works on PHP5 + for Windows and needs no separate installation. So you do it like this:

<?php $obj = new COM("myfsharp.dll"); $output=$obj->HelloWorld(); // Call the "HelloWorld()" method from the DLL. // once we created the COM object this can be used like any other php classes. echo $output; ?> 

And , if you are skeptical about using the PHP COM class , then read this from the PHP Manual :

Starting with PHP 5, this extension (and this documentation) was rewritten from scratch, and most of the old tangled and dummy crack was removed. In addition, we support the creation and creation of .Net collections using the COM compatibility level provided by Microsoft.

This article shows all the changes made.

+4
source

Phalanger should be able to directly call F # code (like any other compiled .NET code). The code will be the same as when working with standard types of PHP (although Phalanger has extensions that allow you to use .NET-specific things, such as generics - which can be difficult using PHPCOM).

The requirements for running F # code from a PHP site compiled using Phalanger are only .NET 2.0+ and IIS (to host the website). For F #, you will need to reference your F # library and FSharp.Core.dll (which contains the F # runtime and basic types).

PS: I have been working with Phalanger for some time, so if you have any questions, let me know - I can send them to the current developers (they can also provide some commercial support if you were interested).

+4
source

Phalanger seems to work better on what it does, and since it effectively makes PHP the .NET language, it is an obvious choice for interacting with other .NET languages. Quite a lot of changes to your PHP code, although I would have thought.

If this does not work for you, I agree with Max above. Use WebService if it runs on a single server, it will still be quite fast and has the advantage that it could be deployed on Mono and mod_mono on other server platforms than Windows.

0
source

All Articles