PHP and Java are very different beasts. Translating Java to PHP is likely to be so technically difficult that it next to impossible to implement for a subset of Java / JEE functionality that was large enough to be worthwhile.
You'd do better either:
- learning and using PHP,
- implementing your entire server in Java, or
- using a bridge that allows you to call into an embedded JVM from PHP; for example, palava (thanks @Willi).
EDIT
@nhbh comments thus:
PHP is very similar to Java nowadays. It supports object orientation, can be executed from the command line without web request and can maintain a global state across requests using ACP. So writing a cross compiler from Java to PHP would be rather easy. But of course it is a huge amount of work to port API calls, so I doubt it is worth the trouble.
There are obvious similarities between Java and (OO) PHP. But there are fundamental differences as well that make translation problematic:
There are fundamental difference between Java primitive / builtin types and their PHP equivalents. Java integer and floating point types don't map directly because of range considerations. Java Strings don't map because PHP strings use 8 bit characters. These will cause problems getting simple Java code to work correctly when translated to PHP.
Java's threading, synchronization and the underlying memory model are probably untranslatable.
Java dynamic classloading, reflection, security and object serialization APIs are probably untranslatable. (In the last case, I would claim that a mapping is only complete if it produces byte-for-byte compatible serializations.)
Creating bridging APIs for the breadth of the Java APIs would be a huge task.
Interfacing with native PHP is likely to cause problems; e.g. Java calling PHP and vice versa, and Java code dealing with objects/values created by PHP code.
In summary, a full-function Java to PHP translator is probably next to impossible. The best you could hope to achieve would be a partial translator that only worked for a small subset of real-world Java code.