I am coding a web application in PHP and it has some performance intensive parts that I'd like to rewrite in a compiled language. I know that I could probably get this done more easily just by writing a C++ extension for PHP, but I'm a bit too spoiled by managed languages like C#, so I'd like to avoid C++ if possible.
If I wanted a PHP script to execute a function inside of a running C# (on mono) process, how could I do this? My first guess is to have PHP open a socket to the C# process, do the work, and close the socket, but I think that would add unnecessary overhead.
Are named pipes something that could solve this problem? If so, do they work on windows (my development machine), and how do I use them from C#?
If not, what other options do I have?
1) To take something from C++ app PHP connects to that app using stream_socket_client function. C++ app is listening on host and port using socket , bind and listen functions. As soon as connection arrives C++ app accept it and then in a separate std::thread serves it ( recv to get request, send to send response).
Have you considered using the PHP.NET compiler, Phalanger?
Another option is to write a PHP module that embeds the Mono runtime in your application.
Here is the documentation on embedding the Mono runtime in your application, in this case, it would be PHP:
http://mono-project.com/Embedding_Mono
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With