Comments (14)
Hi, you are right, installing of v8js on modern versions of PHP is confusing because the documentation is not up to date.
On the other hand, the latest version available in PECL specifies that it does not support php8:
https://pecl.php.net/package-changelog.php?package=v8js&release=2.1.2
I was able to install v8js on php 8.2.9 after a few minutes examining the config.m4 file and my old v8js installation on php 7.2.
Here is an installation guide for debian bookworm and php 8.2.9.
v8 library installation:
apt install libnode-dev
After installation it is necessary to copy the files with the structure needed by v8js for compilation:
mkdir /opt/v8
mkdir /opt/v8/lib
mkdir /opt/v8/includes
copy v8 files from /usr/lib/x86_64-linux-gnu/, to /opt/v8js/lib.
ls /opt/v8/lib
libnode.so libnode.so.108 libv8.so libv8_libbase.so libv8_libplatform.so libv8_libsampler.so
copy v8 includes from /usr/include/v8 to /opt/v8/include
cp -r /usr/include/v8/* /opt/v8/include/
Installing v8js
cd /opt/
git clone https://github.com/phpv8/v8js.git
cd v8js
phpize
./configure --with-v8js=/opt/v8 LDFLAGS="-lstdc++"
make
make test
make install
Then add extension=v8js.so to your php.ini file
from v8js.
@art-fatal I managed to install it on CentOS 7 + remi, dm me if you need help.
from v8js.
FWIW this is why I created https://github.com/joehoyle/php-v8js which is a re-implementation of this lib. V8 is included directly on the pre-built php extension so there's no need to mess around with trying to install libv8 on the system
from v8js.
Followed :
https://github.com/phpv8/v8js/blob/php8/README.Linux.md
Error :
ninja -C out.gn/x64.release/
ninja: Entering directory `out.gn/x64.release/'
[1/1] Regenerating ninja files
[85/2025] ACTION //src/inspector:protocol_generated_sources(//build/toolchain/linux:clang_x64)
FAILED: gen/src/inspector/protocol/Forward.h gen/src/inspector/protocol/Protocol.cpp gen/src/inspector/protocol/Protocol.h gen/src/inspector/protocol/Console.cpp gen/src/inspector/protocol/Console.h gen/src/inspector/protocol/Debugger.cpp gen/src/inspector/protocol/Debugger.h gen/src/inspector/protocol/HeapProfiler.cpp gen/src/inspector/protocol/HeapProfiler.h gen/src/inspector/protocol/Profiler.cpp gen/src/inspector/protocol/Profiler.h gen/src/inspector/protocol/Runtime.cpp gen/src/inspector/protocol/Runtime.h gen/src/inspector/protocol/Schema.cpp gen/src/inspector/protocol/Schema.h gen/include/inspector/Debugger.h gen/include/inspector/Runtime.h gen/include/inspector/Schema.h
python ../../third_party/inspector_protocol/code_generator.py --jinja_dir ../../third_party/ --output_base gen/src/inspector --config ../../src/inspector/inspector_protocol_config.json --inspector_protocol_dir ///third_party/inspector_protocol
Traceback (most recent call last):
File "/tmp/v8/out.gn/x64.release/../../third_party/inspector_protocol/code_generator.py", line 725, in <module>
main()
File "/tmp/v8/out.gn/x64.release/../../third_party/inspector_protocol/code_generator.py", line 601, in main
jinja_env = initialize_jinja_env(jinja_dir, config.protocol.output, config)
File "/tmp/v8/out.gn/x64.release/../../third_party/inspector_protocol/code_generator.py", line 190, in initialize_jinja_env
import jinja2
File "/tmp/v8/third_party/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "/tmp/v8/third_party/jinja2/environment.py", line 16, in <module>
from jinja2.defaults import BLOCK_START_STRING, \
File "/tmp/v8/third_party/jinja2/defaults.py", line 32, in <module>
from jinja2.tests import TESTS as DEFAULT_TESTS
File "/tmp/v8/third_party/jinja2/tests.py", line 13, in <module>
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
[86/2025] SOLINK ./libv8_libbase.so
FAILED: libv8_libbase.so libv8_libbase.so.TOC
python "../../build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="nm" --sofile="./libv8_libbase.so" --tocfile="./libv8_libbase.so.TOC" --output="./libv8_libbase.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,-soname="libv8_libbase.so" -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,defs -Wl,--as-needed -fuse-ld=lld -Wl,--icf=all -Wl,--color-diagnostics -m64 -Werror -rdynamic --sysroot=../../build/linux/debian_sid_amd64-sysroot -L../../build/linux/debian_sid_amd64-sysroot/usr/local/lib/x86_64-linux-gnu -L../../build/linux/debian_sid_amd64-sysroot/lib/x86_64-linux-gnu -L../../build/linux/debian_sid_amd64-sysroot/usr/lib/x86_64-linux-gnu -Wl,-rpath=\$ORIGIN -Wl,-O2 -Wl,--gc-sections -o "./libv8_libbase.so" @"./libv8_libbase.so.rsp"
Traceback (most recent call last):
File "/tmp/v8/out.gn/x64.release/../../build/toolchain/gcc_solink_wrapper.py", line 151, in <module>
sys.exit(main())
File "/tmp/v8/out.gn/x64.release/../../build/toolchain/gcc_solink_wrapper.py", line 134, in main
result, toc = CollectTOC(args)
File "/tmp/v8/out.gn/x64.release/../../build/toolchain/gcc_solink_wrapper.py", line 44, in CollectTOC
result, toc = CollectSONAME(args)
File "/tmp/v8/out.gn/x64.release/../../build/toolchain/gcc_solink_wrapper.py", line 27, in CollectSONAME
if 'SONAME' in line:
TypeError: a bytes-like object is required, not 'str'
[87/2025] CXX obj/third_party/googletest/gtest/gtest-filepath.o
ninja: build stopped: subcommand failed.
from v8js.
Hi, you are right, installing of v8js on modern versions of PHP is confusing because the documentation is not up to date.
On the other hand, the latest version available in PECL specifies that it does not support php8:
https://pecl.php.net/package-changelog.php?package=v8js&release=2.1.2
I was able to install v8js on php 8.2.9 after a few minutes examining the config.m4 file and my old v8js installation on php 7.2.
Here is an installation guide for debian bookworm and php 8.2.9.
v8 library installation:
apt install libnode-dev
After installation it is necessary to copy the files with the structure needed by v8js for compilation:
mkdir /opt/v8 mkdir /opt/v8/lib mkdir /opt/v8/includes
copy v8 files from /usr/lib/x86_64-linux-gnu/, to /opt/v8js/lib.
ls /opt/v8/lib libnode.so libnode.so.108 libv8.so libv8_libbase.so libv8_libplatform.so libv8_libsampler.so
copy v8 includes from /usr/include/v8 to /opt/v8/include
cp -r /usr/include/v8/* /opt/v8/include/
Installing v8js
cd /opt/ git clone https://github.com/phpv8/v8js.git
cd v8js phpize ./configure --with-v8js=/opt/v8 LDFLAGS="-lstdc++" make make test make install
Then add extension=v8js.so to your php.ini file
thanks, it's work for me with php8.0
from v8js.
Thank you very much ! before posting this message, i was frustrated because i have spent a lot of time trying to install this library.
I finally succeeded few hours after this message, in another way that your way. But your way is easier and better.
I encountered many compilation errors, one was because the prototype of a function mismatch between the v8 lib and this lib.
So i take my courage at two hands and decided to edit the C code by myself to fix the prototype. And after recompiling, it worked.
But thanks for considering my message and to give to everyone a working and easy solution. I'm sure that it will help a lot of people.
from v8js.
@jcastilloa do you know how to do with CentOS 7?
from v8js.
@jcastilloa do you know how to do with CentOS 7?
@art-fatal, I think so, try installing the packages nodejs-libs and nodejs-devel to provide the v8 library and the includes
from v8js.
@tbarillet did you manage to install it on CentOS?
from v8js.
@joehoyle i get that you’re trying to help but using issues as a means to divert people away from a project kinda feels a tad awkward and not really in the spirit of open source projects
from v8js.
@art-fatal I managed to install it on CentOS 7 + remi, dm me if you need help.
Perhaps you’d be ok to paste the details here? Then we can probably update the documentation for others :)
from v8js.
I was able to get this building on Alpine 3.19 by installing the nodejs-dev
package and linking to the libnode.so
from that package, which bundles a version of v8 and contains the necessary libv8 symbols. All tests pass.
You can see the changes I made to v8js for this here — I just replaced various references to the various v8 libraries in config.m4
with the monolith node library.
It would be nice to make this something that could be merged back — i.e., update the autoconf logic such that it autodetects and links with either libv8 or libnode, depending on which is present — but I don't know autoconf well enough to really make that change (and don't have the time needed to learn it).
from v8js.
@Westacular I guess you could open a PR with the changes
from v8js.
Here's how my Dockerfile looks like, this example is with php 8.3 and Debian 12.
It uses libnode and symlinks the required folders.
https://gist.github.com/dinamic/60a573e6ffa8749f94931a4d7cfcfcb8
from v8js.
Related Issues (20)
- Trying to compile with php8 branch on ubuntu 22, getting error: could not determine libv8 version (v8 compiled succesfully) HOT 3
- Dynamic Properties deprecation in PHP 8.2 HOT 4
- Broken build on PHP 8.0.x HOT 2
- Segmentation fault - possibly another GC issue? HOT 7
- Compromise between FORCE_ARRAY and standard setup HOT 8
- sandbox error with v8 11.1.277.13 HOT 1
- libv8 must be version 9.0 or greater (using dockerfile) HOT 1
- Issue running make in ubuntu 22.04 HOT 2
- windows php 8.1
- compile error with g++ 13: error: expected unqualified-id before '&' token
- With wich version of V8 this php library work ? HOT 4
- Error installing on debian 11
- PROHIBITS_OVERWRITING removed from V8 and causing V8Js compile error. HOT 1
- V8Js 3.0.0 HOT 1
- Is the latest recommended release 2.1.1 or 2.1.2? HOT 4
- Do I have permission to refactor this? HOT 3
- Compilation error: "no matching function for call to 'v8::ObjectTemplate::SetAccessor" HOT 6
- Linux arm64 support? HOT 3
- Is there an official installation tutorial for the v8js extension? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v8js.