What is the best way to convert an existing php class into Java?

前端 未结 15 1205
梦毁少年i
梦毁少年i 2021-02-09 14:07

I have been tasked with converting several php classes into java classes, which is quickly becoming a nightmare for me. I understand the basic language structure, it being simil

相关标签:
15条回答
  • 2021-02-09 14:43

    A human is the best tool.

    I would try to rewrite the php to remove most of the php features to something C like. Then you'll have an easy time rewriting in Java.

    But I need to ask, why do you need to convert the php? Can you not wrap the php into something callable from Java? This way you won't add any errors while converting it.

    0 讨论(0)
  • 2021-02-09 14:44

    I would normally take the class generated by php5servlet, a jar thats available in tomcat & resin.

    Then change the class file to Java.

    cheers

    0 讨论(0)
  • 2021-02-09 14:46

    I can only find two:

    1) https://github.com/bafolts/java2php

    2) http://www.runtimeconverter.com/

    There is also Caucho Resin, but it is not exactly a converter. It is an implementation of php inside of Java.

    There is a whole lot on the internet about numiton, but their website is down for several years now.

    0 讨论(0)
  • 2021-02-09 14:47

    I said this in the PHP Optimization Tips question and I'll say it again here: If you're running PHP from a static environment (web server module or FastCGI), use an opcode cache, such as APC. Otherwise, PHP is reinterpreting/recompiling your code on every request!

    0 讨论(0)
  • 2021-02-09 14:48

    For completeness, I should point out that there is a PHP runtime for the JVM. Check out Quercus.

    You might consider leaving your current codebase in PHP and just getting it to run on the JVM. You can then rewrite code in Java as needed.

    0 讨论(0)
  • 2021-02-09 14:48
    1. throw code away
    2. rewrite in java
    3. ????
    4. profit!
    0 讨论(0)
提交回复
热议问题