views:

81

answers:

1

hello,

i wonder, if there's any transpiler available, which converts (simple) php code to javascript?

what i am not looking for is ajax stuff or javascript libraries imitating php functionality, but i am looking for a translater, which is able to generate javascript code from php code (similar of what google is doing with GWT and the java-to-javascript transpiler).

thanks!

+1  A: 

You can use something like this: http://www.harmony-framework.com/
But notice, that Javascript has lots of security issues PHP avoids. And straight conversion is not always possible for Database-related function calls or some other PHP extensions

alemjerus
my comment to the question applies: eg, harmony translates `array($a => 'foo')` to `{a : 'foo'}`; depending on the problem harald is trying to solve, something like http://haxe.org/ which can compile to both PHP and JS might be a better solution
Christoph
thanks -- i'll have a close look at both, harmony and haxe ...
harald
mmm -- harmony seems to be a little outdated -- the webpages last change was in 2008. do you know, if they are still working on it? i think harmony would fit my needs better than haxe, even though haxe seems to be very advanced. but i don't know how i would integrate haxe with my app, because my app is already implemented in php ... only the php->javascript part is missing, which would help speed up development and make things more convenient ...
harald
@harald: if you look at the svn commit feed of harmony ( http://code.google.com/feeds/p/harmony-framework/svnchanges/basic ), you'll see that development is slow, but I don't think it's dead; the documentation an how to wrap PHP code for haxe seems somewhat... incomplete: http://haxe.org/doc/php/extern_libraries; if all that's missing from your application is some JS, porting it to haxe will be overkill
Christoph
i mark this as answered, because this harmony thing seems at least to be a very good starting point for this. thanks you both!
harald