PHP server?

xoraxxorax Member Ivan BrykovOrganization: Opticsplanet inc

Hi!

We have a lot of PHP code in my company. Some parts are huge monoliths, some are small API endpoints. I was thinking to introduce ICE into this ecosystem. But according to the docs PHP cannot act as a server. Only as a client. So here is the question: is there any reasonable solution? Is there a way I can reuse PHP code on the server side?

Tagged:

Answers

  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff

    Hi Ivan,

    It's a limitation of the Ice for PHP language mapping, and there is no straightforward solution.

    You could write your server in another language (such as C++, C#, Java or Python) and then delegate the actual implementation to your PHP code. It's probably fine for a small server with a few operations.

    A better solution would be to add server-side support to Ice for PHP. It's doable but quite some work.

    Best regards,
    Bernard

  • xoraxxorax Member Ivan BrykovOrganization: Opticsplanet inc

    Hi Bernard,

    Thank you for this answer. I was thinking about creating some sort of proxy/relay server in Python. The idea is as follows:
    1. it listens for incoming connections and invokes corresponding PHP script with parameters;
    2. PHP script connects back to this server using the ICE and the same slice definition and submits the result of its work;
    3. the server then just forwards the response to the initial client.

    Sounds a bit crazy to me to be honest. And there is some part that leaves me puzzled. This relay server will need to hold the requests without knowing when there is going to be a result and which result corresponds to which request. So I'll need to implement some sort of job queue inside of this server and identify response from PHP properly based on some sort of job uuid or something.

    The good thing though is that this implementation can be flexible enough to work with any PHP code.

    And I wonder if I'm inventing a wheel here?

  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff

    Hi Ivan,

    Your idea could work, but I agree, it's not an elegant solution.

    You could go one step further and retrieve the input parameters with an Ice call from PHP to your Python server. This way, you may be able to write your Python relay server in a generic way, using Blobjects to forward the input parameters and results.

    This could be ok for a few operations, but not great as a general solution. There is basically no way to emulate server-side support when all you have is client-side, and that's true for all client-side only language mappings (PHP, Ruby, MATLAB).

    If a language mapping supports callbacks over bi-dir connections (like JavaScript), then it's easy to emulate server-side support: you can create a "relay server" that forward the requests to the client/server over a bi-dir connection.

    Best regards,
    Bernard

  • xoraxxorax Member Ivan BrykovOrganization: Opticsplanet inc

    Bernard, I was thinking about retrieving requests from the server with PHP script, too. But I didn't see that part about Blobjects and thought it would be too complicated. Thank you for this reference, I'll investigate this option as well. Ultimately, my goal is to introduce ICE into our infrastructure and to my team. After that we can start refactoring our codebase using Python or Java. So I hope it might work.

    Can you also express your opinion onto whether it's reasonable to start relying on ICE in 2019? The thing is that I don't see much going on this forum and on github and I will need to explain that to my team, too.

  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff

    Hi Ivan,

    Other than for writing PHP servers, Ice is certainly a good choice in 2019 and beyond.

    Ice is a proven product, not a rapidly changing project with big changes all the time. The result is somewhat long release cycles, which has some advantages: each release is thoroughly tested and you don't need to upgrade every couple months to stay current. We are also very careful with binary compatibility (for patch releases) and over-the-wire compatibility (for all releases). If you start developing with Ice today, there is a good chance you can upgrade your application to the latest Ice in 2, 3 or 5 years and not start everything from scratch.

    Proven doesn't mean stale. We are just about to release Ice 3.7.2 with bug fixes and some new features.
    The most recent "big" addition was DataStorm alpha, released in October. And in the next few months, we'll release another DataStorm iteration, a new Swift mapping, and more... could be even PHP server-side support if one our customers wants to sponsor this development.

    Cheers,
    Bernard

  • xoraxxorax Member Ivan BrykovOrganization: Opticsplanet inc

    Bernard, thank you so much. This was very helpful!

Sign In or Register to comment.