Home  |  Linux  | Mysql  | PHP  | XML
From:Tomas Petricek Date:Fri Feb 15 10:22:54 2008
Subject:RE: Re: Lang.Net Symposium 2008
Hi,
the topic that Rob pointed out is I think quite interesting.

>> I am working on an implementation of PHP which runs on a JVM. 
>> Like Phalanger, we wanted to make use of  existing PHP extensions 
>> so we were faced with the problem of attaching these 
>> extensions to a managed runtime.

The implementation in Phalanger that makes this possible for PHP4 extensions
uses a native DLL with the same interface as native PHP4 core library used
by the extensions. This library is written in a mixed (unmanaged/managed)
code, so it can perform calls to the Phalanger runtime to mimic the behavior
expected by the extensions. The reason why Phalanger supports only PHP4
native extensions is that this interface is growing more and more complex,
which makes it extremely difficult to implement this "bridge" library, so of
course simplifying this interface would help us a lot in a same way to Robs
JVM implementation (and I that that you'll agree that loose coupling between
these two components is clearly better design that would be beneficial to
the official PHP implementation too).

When it comes to running PHP in Silverlight (I'm not saying DLR, because DLR
runs on both Silverlight and full .NET CLR) the situation is more tricky -
for security reasons it is not possible to run any native code in
Silverlight, so the only way to support PHP extensions written in C is to
reimplement them in some managed language (interestingly - it is possible to
re-implement them in PHP and compile them using Phalanger). 

I can't see any easy way to make these extensions portable, other than
implementing as much as possible extensions in PHP. It would help to have
some easy way for calling "native" functions from PHP (in a similar way in
which you can call C functions from C# - see
http://www.devx.com/dotnet/Article/6990). That would enable writing more
extensions in PHP and the alternative implementations (JVM,DLR) could just
provide implementation for some native functions. For example - some
extension that manipulates with file system would just "import" the
necessary core functions from some C library and DLR/JVM implementation
would have to implement .NET/Java alternatives of these C functions, but the
rest of the source code (written in PHP) could be re-used.

Thanks,
Tomas
Navigate in group php.on.dlr at sever news.php.net
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants