Migration from PHP to Java

Hey everybody!

I'm not sure that this is the place to ask such a question, but i'm trying to perform Migration from PHP to Java and there are several issues i have to figure out before starting.

Unfortunately i have 3 questions and only 125 points (I'll increase these point later on). So here they are:
Q1: I found a site that looks quite interesting: http://www.datatek-net.com/dtk_conversion.htm?t
Can anyone recommend some other companies, since they probably don't migrate PHP to Java (haven't recieved answer yet).
Actually i'm not sure, that this can be done automatically at all, because an ordinary PHP page has php mixed up with html, css, javascript and sql. Compared to, let's say C, it looks quite tough to me! So can it be done automatically and how (company, program, etc)?

Q2: The second easy way out is to use a PHP/Java Bridge. http://www.zend.com/products/zend_platform/in_depth/php_java_integration
this one looks quite tempting and this could save us a lot of time, because then we could do an integration and migrate to java step by step, not stop most of the development and start wrinting the same thing in Java. Is it as good as it is said on this zend page and what's the catch (there has to be one)?

Q3: This is the way, it is planned now. Manually rewrite the entire system (about 5 million lines of code) in Java. It will take a lot of time and a lot of effort, but it has some good points: the code will be cleaned up, no deprecated stuff in it, better organized code, etc. From the info found in google, the common trend looks like migrating to PHP not from PHP. So if anyone has experience with this, please share your know-how and experience with me.

Thanks in advance
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richard QuadlingSenior Software DeveloperCommented:
Mixed up code is simply badly designed code. ALL code can be "mixed up" if written badly enough.

What is the reasoning of going to Java rather than doing the refactoring in PHP?

You obviously have the PHP skills to generat the 5 million lines of code (Assuming you're not talking about the mixed up code - in which case take out the HTML/JS/CSS and how much is left).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
To try to answer all three questions at once:

If you have the skills, time and budget I would totally go for option 3.

Option 1 seems impossible to me; developing automated conversion of mixed PHP (probably not even object oriented code) to an Object Oriented language like is just not worth it, I can 't imagine anyone would have done such a thing :) C/C++ to Java conversion would be doable, I guess. Unless someone can give you an out-of-the-box solution, but that would really surprise me.

Option 2 seems like a bandaging method to me in any case, but they might be a solution in cases where there's time and money involved.

I know that my employer would neve let me do option 3 - unless a client would want it, but then he would pay dearly ;)
spec1o1Author Commented:
First of all, thank you for your answers.

RQuadling: I agree, the design is not the best, but still, it is better than you think it is ;). It's actually better organized and structured compared to anything I have seen before. "Mixed up" means just that there are still many files which have HTML and JavaScript and PHP in them.
I’m trying to give you a quick answer on why we are doing such migration, but there is none. Maybe PHP vs Java = MySQL vs Oracle?
PS! Please don't take it as an insult, it's not meant as one, but this is not the subject of this discussion. It is already decided and it really doesn’t really matter that much (to me) at the moment if we have to migrate 1 million or 10 million lines – it's a hell of a job and I just need to know what is the best way to do it.

derkesthai: There is quite a lot of code that actually is object oriented. That conversion should not be too hard to perform even manually, because OO PHP and Java are not too different. Actually the data type conversion is probably going to be the first problem I can think of. But ok, I agree with you - the automatic conversion seems impossible and it probably is too. Also i didn't recieve any answer from this "datatec" company.
I agree with you on the third option as well, but unfortunately there is time and money involved.  And the third option is something that we are willing to accept, but only if there are no other ways to do it.

So I still would like to know about that PHP/Java bridge. Has anyone used it? Does it really work that well?

Has anyone performed a migration from PHP to Java? How did you plan it? What are the main issues? Risks? Biggest problems that occurred during? Things you could have done better and what you wouldn’t do next time? Suggestions?
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Well, the best option I can think of (I'm by no means an expert on migrating code..) would be to keep the PHP code for the time being, and implement some sort of Java middle tier that communicaties with both Java and PHP code -- in the end it's all HTML (or something similar) that your web application returns, so it doesn't really matter.. you can then continue developing in Java, well keeping the PHP code as legacy code.. You might need to implement some interface on you PHP code that the Java layer can communicate with..

This is basically the same idea as the Zend example you gave in your initial post, but there PHP proxies Java, and not the other way around.

In short: write a java program that will call you PHP code and "forward" the results from your Java program.

A bit simplistic put maybe, but I think you know what I mean :)
spec1o1Author Commented:
Thank you derkesthai, your comments have been very useful. That last example was interesting as well, I'll look into it.

I forgot to ask in the first post, are there any other options?
I'll keep this question open for another week or so. If you are reading this, please add your opinion. Sometimes even the most simple idea could conduct to the best solution ;)
I was wondering.. WHY are you migrating?
Don't know which approach have you finaly decided to go with. However, here is something that I found that could be relevent for you.



It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.