run JavaScript code in PHP 5.3 with the v8js extension

…for some reason i needed to get t h i s to work before going to sleep.

I’m running OSX 10.7.3 with macports which usually does the job, but  Google’s V8 Javascript Engine is not available as a port yet.

So… homebrew to the rescue:

installed it:

/usr/bin/ruby -e "$(/usr/bin/curl -fsSL"

and installed v8

brew install v8

wait, this seems too easy.

PECL installed some beta version of the PHP extension.

sudo pecl install channel://


to the php.ini file.

und bitteschön:

$v8 = new V8Js();

//hey i'm Javascript Code


var hello = 'Hallo';

function helloWorld( string ){
return hello + ' ' + string;



Such things might come in handy one day, you know.