如何使用PHP访问单声道本机代码

Ahead of Time Compilation or AOT is a feature of the Mono runtime code generator.

mono --aot program.exe

This will generate a file called "program.exe.so"

  • How can i load this shared object file in php script and access the class objects and methods. ?

Thanks

The native library still needs to be loaded inside an AppDomain (i.e. the Mono VM/runtime) in order to run, it is not a native library as such.

If you must I'd suggest looking at

  • whether php supports COM interop (I don't use php, but I'd reckon the chance exists). This would be good since you could use that and profit from OO interface exposure

  • Use Swig which has support for C# some time now

  • Alternatively, use mkbundle, and/or create a native shared library that embeds a Mono VM. The shared library wrrap around the C# interface using a "C" native API's.

The Phalanger project should be able to do this. You can compile your php code with mono and also integrate with .net from php.