Any docs about V8JS in PHP?

偶尔善良 提交于 2019-12-12 18:17:38

问题


Is there any documentation about V8JS? Do I need only standard PHP or some extensions to use V8JS?

I'll be very thankful for any information about V8JS in PHP.


回答1:


Requirements

PHP 5.3.3+ and V8 library and headers installed in proper paths.

Install




回答2:


I've found this docs on the v8js class.




回答3:


The docs out there aren't complete or are not updated. I'm actually currently in the process of doing v8JS myself and it took me a few days to get the back end libs sorted out. First off, you must know that you can't do this is you have python < 2.7

Here is my install notes that I'm putting together for our dev vagrant boxes running centos 7.

cd /tmp

# Install depot_tools first (needed for source checkout)
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"

# Download v8
fetch v8
cd v8

# Build (disable snapshots for V8 > 4.4.9.1)
make native library=shared snapshot=off -j8

# Install to /usr
sudo mkdir -p /usr/lib /usr/include
sudo cp out/native/lib.target/lib*.so /usr/lib64/
sudo cp -R include/* /usr/include
echo -e "create /usr/lib64/libv8_libplatform.a\naddlib out/native/obj.target/tools/gyp/libv8_libplatform.a\nsave\nend" | sudo ar -M

cd /usr/lib64
sudo chrpath -r '$ORIGIN' libv8.so

========================
Compile php-v8js itself
========================
cd /tmp
git clone -b master https://github.com/phpv8/v8js.git
cd v8js
phpize
./configure
make
make test
sudo make install

sudo service httpd restart

A note on the line make native library=shared snapshot=off -j8. I had the compile stop on me a couple times, I just restarted it. I'm not sure why it stopped, but it restarted just fine and completed just fine.

After that is done, you need to create the php extension file /etc/php.d/v8js.ini with the following content

; Enable v8js extension module
extension=v8js.so

Run the following to make sure it is installed correctly

php -r "phpinfo();" | grep v8js

If you get output back and no errors you're good to go.



来源:https://stackoverflow.com/questions/5070278/any-docs-about-v8js-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!