Is there some api available for embedding javascript in php – something similar to Jint for .NET.
I would like to allow user to customize workflow by being able to access limited php classes and methods that can be run at server-side.
User writes a code block that gets executed later… for example, js/ecma script code like …
if (Contact.Age < 12){
Contact.setEligibility = false;
}
else{
Contact.setEligibility = true;
}
There’s a pseudo-Javascript interpreter called ‘phpjs’ (php functions implemented in javascript), which I happen to know about. And a fully syntax compatible JS interpreter (written in pure PHP) called Javascript for PHP5: http://j4p5.sourceforge.net/ – implements the JS language, not the DOM or much functions.
If you want a full-fledged and “real” Javascript runtime, then there is a PECL extension for that. http://pecl.php.net/package/spidermonkey (requires custom compiling PHP interpreter).