Mathieu Hays

I recently had interest in generating a React-based web app using PHP. To be able to do such an amazing thing you first need to install the PHP extension V8Js. You’ll find below the process I followed to install it on my Mac:

First install the engine:

brew install v8

Install dependency for the PECL Extension:

brew install autoconf

Update Pear:

cd /usr/lib/php
sudo php install-pear-nozlib.phar

Then edit your php.ini by adding the following line next existing include_path if not already there

include_path = ".:/usr/lib/php/pear"

Update/Upgrade Pear / PECL

sudo pear channel-update pear.php.net
sudo pecl channel-update pecl.php.net
sudo pear upgrade-all

Grab V8Js PECL Extension from github & install it

cd ~
mkdir tmp && cd tmp
git clone git@github.com:preillyme/v8js.git
cd v8js
phpize
./configure CXXFLAGS="-Wno-c++11-narrowing"
make
make test # if this step fails you can try make install anyway, should work.
make install

Then edit your php.ini again to add the following line:

extension=v8js.so

All you need to do now is to restart Apache and it should work !

sudo apachectl restart

I can’t guarantee it’ll work for everyone, especially that it might be time sensitive given the compatibility between versions. Hopefully it’ll help some of you 🙂

Obviously I won’t recommend using this in production as it might not be stable.

Edit: 28/01/16 – Update instructions