sudo apt-get install build-essential curl git python libglib2.0-dev
cd /tmp
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"
fetch v8
cd v8
For php 7.4 support added in this commit - https://github.com/stesie/v8js/commit/ab6e2267afefa8f4e0c34c6be115acc14c5cad1d - MAYBE WILL NOT WORK! Use 7.2 instead
git checkout 7.0.276.3
git checkout 6.4.388.18
gclient sync
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2
sudo update-alternatives --config python - CHOOSE PYTHON 2.7
tools/dev/v8gen.py -vv x64.release -- is_component_build=true use_custom_libcxx=false
ninja -C out.gn/x64.release/
sudo mkdir -p /opt/v8/{lib,include}
sudo cp out.gn/x64.release/lib*.so out.gn/x64.release/*_blob.bin \
out.gn/x64.release/icudtl.dat /opt/v8/lib/
sudo cp -R include/* /opt/v8/include/
sudo apt-get install patchelf
for A in /opt/v8/lib/*.so; do sudo patchelf --set-rpath '$ORIGIN' $A; done
Compile php-v8js itself
cd /tmp
git clone https://github.com/phpv8/v8js.git
cd v8js
phpize
./configure --with-v8js=/opt/v8 LDFLAGS="-lstdc++"
make
make test
sudo make install
Then add extension=v8js.so to your php.ini file. If you have a separate configuration for CLI, add it there also.
V8Js' build system assumes that the icudtl.dat file is located next to the libv8.so library file and compiles the path into the library itself. If for whatever reason the icudtl.dat file is stored at a different place during runtime, you need to set the php.ini variable v8js.icudtl_dat_path to point to the file. Otherwise locale-aware features of V8 will not work as expected.