JPHP是一个类似于javac的编译器,它能够将PHP源代码编译成JVM字节码的编译器。然后就实现了让PHP程序运行在Java虚拟机器上。 它支持许多PHP5.3+的特性。JPHP与 JRuby和Jython相似。
支持: JDK 1.6+ (OpenJDK, Oracle)。
目标
JPHP不是 Zend PHP 引擎或Facebook HHVM的一个代替。它并不想实现zend运行库(比如:Curl, PRCE等)。这个项是为了:
- 能够在PHP中使有用Java对象
- 通过 JIT 和 JVM提升性能
- 利用更好的运行时库来代替Zend PHP的丑陋的运行时库
- 让PHP不单只能用于开发Web应用
- Also: unicode for strings and threads
特性
- JIT (2x - 10x faster PHP 5.4)
- Optimizer (constant expressions, inline functions, etc.)
- Using java libraries and classes in PHP code.
- Unicode for strings (UTF-16, like in Java)
- Threading, Sockets
- Environment architecture (like sandbox objects in runkit zend extension).
- GUI (based on Swing, improved - more flexible layouts)
- Embedded cache system for classes and functions
- Optional Hot Reloading for classes and functions
语言支持的特性
(without zend runtime libraries)
- PHP 5.2+ fully support (with OOP)
- Closures (PHP 5.3), auto-binding
$this in closures (PHP 5.4)
- Namespaces fully support (PHP 5.3)
- Spl autoloading for classes (PHP 5.3)
- Iterators, ArrayAccess, Serializable
- Type hinting for classes, arrays, callable (PHP 5.4)
- Array short syntax (PHP 5.4)
- Ternary short cut "?:", NOWDOC,
__callStatic , __invoke (PHP 5.3)
- Late static binding (PHP 5.3)
- GC for cyclic references (PHP 5.3)
Class::{expr}() , (new Foo)->bar() (PHP 5.4)
- Try finally (PHP 5.5)
- Array and string literal dereferencing (PHP 5.5)
__debugInfo for var_dump (PHP 5.6)
- Function array dereferencing has been added, e.g.
foo()[0] (PHP 5.4)
- Constants can be declared outside a class using the const keyword. (PHP 5.3)
- Dynamic access to static methods (PHP 5.3)
- Exceptions can be nested (PHP 5.3)
::class system constant (php 5.5)
还不支持什么?
- Traits (php 5.4)
- Generators (php 5.5)
- Goto (php 5.3)
- list() in foreach (php 5.5)
- Binary number format, e.g. 0b001001101 (php 5.4)
项目主页:http://www.open-open.com/lib/view/home/1395628572618
|