Migration from PHP to Java

Posted on 2006-04-23
Last Modified: 2013-12-12
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:
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.
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
Question by:spec1o1
    LVL 40

    Accepted Solution

    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).

    LVL 3

    Expert Comment

    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 ;)

    Author Comment

    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?
    LVL 3

    Assisted Solution

    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 :)

    Author Comment

    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 ;)
    LVL 3

    Expert Comment

    I was wondering.. WHY are you migrating?

    Expert Comment

    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.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to count occurrences of each item in an array.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now