phpv8 and php-v8 are different.

Recently I chose to upgrade our servers to php7. At the same time it seemed appropriate to upgrade our Ubuntu installations to Xenial Xerus.

Having upgraded to Xenial Xerus, installing php7 (with aptitude) was no issue. I did however have to reinstall the various PHP extensions that our projects utilise.

For example I had to install Phalcon 3 which is now disgustingly easy - it is now hosted on PackageCloud.io.

I also had to install the latest version of the v8 engine and its PHP extension. I previously wrote about compiling the latest versions of v8 and v8js on Ubuntu, but decided to see if anything had changed in terms of the packages available on the latest version of Ubuntu.

Installing the v8 Javascript engine

The READMEs for both phpv8 and php-v8 note that one can install the v8 Javascript engine using the the pinepain/libv8-5.4 PPA. That is easy enough:

$ sudo add-apt-repository -y ppa:pinepain/libv8-5.4
$ sudo apt-get update -y
$ sudo apt-get install -y libv8-5.4-dev

Installing v8.. for PHP

This is where I got a little confused. Having Googled 'v8 PHP', I had found the above link and installed v8.

Not appreciating the dash (-) in the project name I also went about installing php-v8. It wasn't until I was looking at phpinfo() that I noticed the extremely low version number. I also saw some errors in my error log about the class V8js not existing.

A little head scratching later and it hit me that php-v8 is not phpv8. Instead of installing the latest version of phpv8 I had installed a completely different project.

The moral of the story.. no server admin when tired.

It does not help that the phpv8 README links to @pinepain's repos as a recommended way of installing the v8 engine. It is organised confusion :)

Summary

  • Install the v8 engine using @pinepain's PPA - it is super easy and much simpler than compiling it yourself.

  • Compile and install phpv8 OR php-v8 as required (it is easy, and both have informative READMEs) depending on what you need. Note that they are different :P

  • Enjoy the ability to execute Javascript on the server. Isomorphic Javascript - Woo !