Are there any libraries or tools specifically designed to help PHP programmers write Javascript? Essentially, converting the PHP logic into Javascript logic. For instance:
$document = new Document($html);
$myFoo = $document->getElementById("foo");
$myFoo->value = "Hello World";
Being converted into the following output:
var myFoo = document.getElementById("foo");
myFoo.value = "Hello World";
So the $html that is passed in won’t initially be modified by the PHP. Instead, the PHP will convert itself into Javascript which is then appended onto the end of the $html variable to be ran when the variable it output and converted into the client-side DOM.
Of course it would be excellent if more complicated solutions could be derived too, perhaps converting objects and internal methods into javascript-objects, etc.
Sounds like you may be looking for something like http://xajaxproject.org. However, it might be geared more towards ajax functionality.. not all javascript. I toyed with it about 2 years ago but never used it seriously. Might be worth a look.