First check if your PHP has Thread Safety, as we’ll need to know that to download the correct module. You can run a simple command in Windows to check this. It might be possible that you have to navigate to the PHP folder, but you can also find this by using a php_info(); file.

php -i | findstr "Thread"

This will output something like: Thread Safety => enabled

Now download the appropriate v8js module, depending on your PHP version, if you are unsure, you can run php -v to find out your PHP version.

Now that you have all the files you need, extract them in their respective folders:

These files go in your \php\ folder:

v8.dll

icui18n.dll (php7)

icuuc.dll (php7)

And this file goes in your \php\ext\ folder:

php_v8js.dll

Now the last thing you have to do is add the following to the end of your php.in file:

; V8 Javascript Engine Module
extension=php_v8js.dll

Now restart your webserver and you’re all done!

Let’s test it out with a simple script:

$v8 = new V8Js();
$v8->executeString("print('hello world');");

Output: hello world

There we go, it’s as simple as that! Remember that it does not have any sort of DOM, so running commands on window. and document. will not work without first creating the DOM. There are some ways to do this by loading a javascript implementation of the DOM, but that’s for another time.