Total Pageviews

Monday 16 July 2012

运行在JVM上的PHP程序

最近几年,有越来越多的语言能够运行在JVM平台上,之前有Jython(运行在JVM上的Python),然后还有JRuby(运行在JVM上的Ruby),还有Scala、Groovy等等。
在互联网业界应用最广泛的PHP语言最终也来到了JVM平台上,以resin著名的Caucho公司发布了Quercus产品,在JVM上实现了PHP语言的大部分功能。
博客程序(wordpress 3.2.1版本)无需对源程序进行任何修改,直接部署就可以运行。
为什么要将PHP语言运行在JVM上呢?摘录Caucho公司网站上的解释如下:
Performance - simply faster
Quercus outperforms straight mod_php by about 4x for MediaWiki and Drupal.
PHP developers can use Java tools like profilers to get in-depth information about the PHP program performance.
Development - fast, safe, and easy
PHP extensions written in Java are fast, safe, and relatively easy to develop compared to those written in C. Since Java is the library language, developers won't need to be paranoid about third-party libraries having C-memory problems or segvs and are freed to concentrate on solving the objectives at hand.
Capability - powerful Java technologies at the developer's fingertips
Quercus has the best of both worlds: PHP and Java. PHP applications can take advantage of Java technologies like JMS, EJB, SOA frameworks, Hibernate, and Spring.
Security - no more pesky C memory bugs
All Quercus extensions libraries are coded in Java. Therefore, developers do not have to worry about C pointer overruns and segmentation faults from PHP extensions anymore.
Scalability - Massive clusters of PHP
Thanks to Resin, PHP applications can beautifully scale to as many servers as desired.
PHP applications can now enjoy connection pooling, distributed sessions, fail-safe load balancing, and proxy caching. These benefits require no change in the PHP code.
Internationalization - 16-bit unicode
Because Quercus is a Java implementation, it natively supports 16-bit unicode strings and functions. Quercus (in 3.1.0) supports the new PHP 6 internationalization syntax, and the older unicode conversion functions like iconv. Since 3.1.3, the new PHP6 unicode features are off by default but they can be enabled with the PHP ini unicode.semantics=on.
更多关于在JVM上运行PHP的信息可以参见Caucho官方网站:
http://quercus.caucho.com/