links // 2012.07.27 08:20:50 [hh]

PHP in JavaScript ausführen

Wenn man denkt, man hat schon alles gesehn, dann kommt bestimmt einer um die Ecke, der eine weitere Fleißarbeit hinter sich gebracht hat. In diesem Falle handelt es sich um Niklas von Hertzen, der in "JavaScript" einen vollständigen PHP-Interpreter als Virtual Machine geschrieben hat. Wofür? Keine Ahnung. In solchen Fällen redet man gerne von "proof of concept".

Niklas von Hertzen über sein jüngstes Projekt: "This library reads PHP code and transforms it into JavaScript code which can be run in the PHP VM in this library, resulting in same results as with PHP. It starts by tokenizing the PHP code into tokens, which it then uses to build an AST tree. Once the tree has been constructed, the script compiles it into JavaScript that can be interpreted by the VM and then executes it. Any additional unconverted code that gets executed within the VM, such as eval or lambda functions will go through the same process before being executed.

The code can be directly run in your browser, meaning you can execute php code straight out of your browser! It can also be run on node.js, but strongly recommend not to due to potential security issues.

As it might not be as self explanatory, this project is purely a proof-of-concept and should by no means be considered to be used in any sort of production environment."

Direkter Link: