A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearWhat is the best way to convert an existing php class into Java? - page 1
User InfoPosts
What is the best way to convert an existing php class into Java?#1
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 similar to C. It is all of the function calls and class calls that seem to go nowhere and the fact that a var can be declared in the !middle of an expression! that is spinning my head, oh and the fact that there is zero "0" documentation.

What is the best method (and/or) tool (and/or) reference material to convert the php into java code?

edit: There is 3 reasons that I am having to convert the php to java.


The usual reason, my boss told me too.
The php is too slow, it is taking minutes sometimes to run a request to the server.
php is a nightmare to scale and maintain.(at least for us strong typed language types)

posted date: 2008-12-12 11:01:00


Re: What is the best way to convert an existing php class into Java?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-12 11:01:01


Re: What is the best way to convert an existing php class into Java?#3
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.

posted date: 2008-12-12 11:07:00


Re: What is the best way to convert an existing php class into Java?#4
I can not imagine that a tool for this is existing.I did something similar with C++ und Java. It is a pain, but the best is to impement it by your self.Or write it in C and create a dll with a jni warpper to call it from Java. This should be the fastet way.

posted date: 2008-12-12 11:18:00


Re: What is the best way to convert an existing php class into Java?#5
Depending on the PHP code, this may be an almost impossible task. The other way around is much easier. PHP is a very dynamic language, and you can get away with things that are impossible in Java. One particularly disruptive thing is that a PHP variable may change type during execution. This is rarely used though, but it could happen. In addition, since PHP is loosely typed, there are a lot of implicit conversions. Some are coincidental, while others are important for the meaning of the program. And then there is the fact that PHP code isn't strictly object oriented, like Java is. Even in object oriented PHP programs, you will usually see some degree of procedural elements. These can not be mapped directly to Java code.As Pyrolistical, I'm curious as to why you need to convert this code? If it's legacy code, wouldn't it be better to keep the PHP code running, and interface with it through some kind of service interface (SOAP, RPC, others)? You could then gradually replace parts over time.

posted date: 2008-12-12 11:21:00


Re: What is the best way to convert an existing php class into Java?#6
You could probably write something with the Reflection API to do some of this, but you really couldn't do anything with function bodies - you'd end up with stub classes that have no implementation.

posted date: 2008-12-12 11:25:00


Re: What is the best way to convert an existing php class into Java?#7
throw code awayrewrite in java????profit!

posted date: 2008-12-12 11:33:00


Re: What is the best way to convert an existing php class into Java?#8
I've been looking into Groovy as a transition language from PHP to Java. They (the Groovy developers) claim that it compiles to java byte code the same as Java code would.It's also less strict, they have several examples of translation on their website.

posted date: 2008-12-12 11:52:00


Re: What is the best way to convert an existing php class into Java?#9
I'll check it out. thanks

posted date: 2008-12-12 12:01:00


Re: What is the best way to convert an existing php class into Java?#10
the php is too slow.

posted date: 2008-12-12 12:02:00


Re: What is the best way to convert an existing php class into Java?#11
caching tools i should have said.

posted date: 2008-12-12 12:09:00


Re: What is the best way to convert an existing php class into Java?#12
It sounds like you're trying to convert PHP code that is procedural into an OO code base.This is not so much a question of PHP to Java, but rather a paradigm shift. There's no automated way to do it, it's going to be rough. Especially if one code base is badly written.Btw, I would also why are you converting? Is it just performance? And if so, is there nothing you can do to fix the performance issues. I don't think just converting from one language to another will fix it, you'll still have to find the bottleneck.

posted date: 2008-12-12 12:24:00


select page: « 1 2...»
Copyright ©2008-2017 www.momige.com, all rights reserved.