Answer the question
In order to leave comments, you need to log in
Is there a library for translating php code to node.js?
Is there a library for translating php code to node.js?
I have only found this https://php2js.ru/ so far , but maybe there are other more complete solutions?
I don’t plan to use it somehow yet, but in general it’s interesting whether it’s possible to use such a project to copy the wordpress example in JavaScript and run it in node.js
Answer the question
In order to leave comments, you need to log in
Technically, the language itself can of course be translated into another, I think even simple functions will work.
BUT! There will be a lot more but. You won’t get by with the usual translation, since there are many pitfalls and features of the PHP API itself, the principles of operation of many built-in libraries, hacks, crutches and just tricks that people use in their projects, etc.
In such a huge and complex project as Wordpress, this is simply an unrealistic amount.
You often understand even the code of large projects, within the framework of one language (any) it is difficult to translate from version to new version. And then to another language / platform for executing the code.
In any case, this is manual labor, and the automatic translator will only help you translate specific constructions, as well as a huge amount of manual labor for each file / class / function, etc.
It is technically possible, but it will take a huge amount of man-hours, it is easier to write from scratch.
The second option is to find a solution with a conditional virtual machine that executes php code inside a js environment. There were once such packages, but there is no demand and everything has died out. This is also a time-consuming process, you need to run and develop your own such thing.
Therefore, today there are only conditional proxies on node.js that run php scripts on php (in one way or another, but it is php that executes them).
Therefore, we come to the WebAssembly technology, there is, for example, the wasmer project, with which you can run wasmer-php . But again, this is not code translation, but simply running php in a browser environment, js is already purely for managing and running wasmer itself ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question