V8 Javascript Engine for PHP — This PHP extension embeds the Google V8 Javascript Engine
fork from : https://github.com/phpv8/v8js.git

Stefan Siegl 3efec8d428 Remove CVS $Id$ comment lines 10 years ago
js 1c23a38026 Initial import 14 years ago
samples 44c329b953 Add a test of PHP magic functions. 11 years ago
tests af58f4ec9e Catch serialization of V8Function instances 10 years ago
.gitignore 926d160367 ignore run-tests.php helper files 10 years ago
.travis.yml 67edd253f9 add PHP 5.6 to .travis.yml 10 years ago
CREDITS f9d363c64e add Simon Best to credits 12 years ago
LICENSE 964c571b70 fix license issue 11 years ago
Makefile.frag 8e0e573d3f The json extension is not needed for PHP 5.4. 11 years ago
Makefile.travis 99a1d54e9e Travis config update: compile against minimum supported v8 and most recent v8. 11 years ago
README.Win32.md 760e50c705 Mention to download & unpack V8Js itself 10 years ago
README.md c28c9f50f1 introduce V8JsException class 10 years ago
TODO f6a6d1e4b5 Rework JavaScript wrapper for PHP objects. 11 years ago
config.m4 3efec8d428 Remove CVS $Id$ comment lines 10 years ago
config.w32 5ea36016fe code cleanup, part 1 10 years ago
package.xml da53c90f88 Added new "v8js.use_date" ini setting to convert PHP DateTime objects to Javascript Date objects 11 years ago
php_v8js.h dc1475a3ad updated package for beta release and switch license to MIT 11 years ago
php_v8js_macros.h 3efec8d428 Remove CVS $Id$ comment lines 10 years ago
test.php 7e90439cdf Make sure all tests and samples use the new exception class name V8JsScriptException. 12 years ago
v8js.cc 3efec8d428 Remove CVS $Id$ comment lines 10 years ago
v8js_array_access.cc 38bc89e10a Once more fix ZTS build 10 years ago
v8js_array_access.h dba4da9b8b Refactor PHP method call code 10 years ago
v8js_class.cc d269809d8b Move types from php_v8js_macros.h to new headers 10 years ago
v8js_class.h d269809d8b Move types from php_v8js_macros.h to new headers 10 years ago
v8js_commonjs.cc dc1475a3ad updated package for beta release and switch license to MIT 11 years ago
v8js_convert.cc 3efec8d428 Remove CVS $Id$ comment lines 10 years ago
v8js_exceptions.cc 5ea36016fe code cleanup, part 1 10 years ago
v8js_exceptions.h 5ea36016fe code cleanup, part 1 10 years ago
v8js_methods.cc 3efec8d428 Remove CVS $Id$ comment lines 10 years ago
v8js_object_export.cc 6869d318b3 Rename V8Object stuff to v8js_v8object_XXX 10 years ago
v8js_object_export.h 2b897e8bc4 Export extra methods on ArrayAccess 10 years ago
v8js_timer.cc 5ea36016fe code cleanup, part 1 10 years ago
v8js_timer.h d269809d8b Move types from php_v8js_macros.h to new headers 10 years ago
v8js_v8.cc 6869d318b3 Rename V8Object stuff to v8js_v8object_XXX 10 years ago
v8js_v8.h d269809d8b Move types from php_v8js_macros.h to new headers 10 years ago
v8js_v8object_class.cc d269809d8b Move types from php_v8js_macros.h to new headers 10 years ago
v8js_v8object_class.h d269809d8b Move types from php_v8js_macros.h to new headers 10 years ago
v8js_variables.cc f6310f9994 Get rid of V8JS_NEW macro. 10 years ago

README.Win32.md

V8Js on Windows

The V8Js PHP extension is primarily targeted at Unix platforms, especially GNU/Linux. However it is possible (and supported) to build on Windows, using Microsoft Visual Studio.

Building with MinGW or Cygwin is not officially supported; mainly since Google v8 does not support builds on Cygwin (and building it on Cygwin is currently broken).

Compared to installation on GNU/Linux it's way more tedious to install V8Js on Windows, since you need to compile PHP with all its dependencies beforehand.

The problem is that Google v8 requires (at least) Visual Studio 2013 as it uses certain C++11 features not available in Visual Studio 2012.

Unfortunately the PHP for Windows project still relies on either Visual Studio 2012 or Visual Studio 2008. It supplies pre-compiled binary archives of required dependencies, however also compiled with Visual Studio 2008 and 2012 only.

Since it is not compatible to link a v8 compiled with Visual Studio 2013 with a PHP interpreter compiled with Visual Studio 2012, you need to step up and compile PHP with Visual Studio 2013. This requires to compile dependencies as well, if you would like to use certain extensions or e.g. the Apache SAPI.

Compiling v8

The Google v8 project already has excellent step-by-step guide on how to build with gyp.

As a short run through:

Then open a command prompt

cd \
git clone https://github.com/v8/v8.git
cd v8
svn co http://gyp.googlecode.com/svn/trunk build/gyp
svn co https://src.chromium.org/chrome/trunk/deps/third_party/icu46 third_party/icu
svn co http://src.chromium.org/svn/trunk/tools/third_party/python_26@89111 third_party/python_26
svn co http://src.chromium.org/svn/trunk/deps/third_party/cygwin@66844 third_party/cygwin
svn co http://googletest.googlecode.com/svn/trunk testing/gtest --revision 643
svn co http://googlemock.googlecode.com/svn/trunk testing/gmock --revision 410

python build\gyp_v8 -Dcomponent=shared_library
"\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.com" /build Release build/All.sln

(alternatively start build/all.sln ... and build within the Visual Studio GUI)

Compiling PHP

There Build your own PHP on Windows guide on the PHP wiki. However it concentrates on Visual Studio 2008 and 2012. Since you need to use Visual Studio 2013 it doesn't apply very well.

This document concentrates on building V8Js for CLI SAPI (only). In order to enable more extensions you need to provide further dependencies, which may be more or less cumbersome to build with Visual Studio beforehand.

A quick run through:

Open "VS2013 x86 Native Tools Command Prompt"

cd \php-sdk
bin\phpsdk_setvars.bat
bin\phpsdk_buildtree.bat phpdev

mkdir vc12
mkdir vc12\x86
mkdir vc12\x86\deps
mkdir vc12\x86\deps\bin
mkdir vc12\x86\deps\include
mkdir vc12\x86\deps\lib
  • download PHP from http://php.net/get/php-5.5.18.tar.gz/from/a/mirror and unpack to below \php-sdk\phpdev\vc12\x86
  • from \v8\build\Release\lib copy icui18n.lib, icuuc.lib and v8.lib to deps\lib folder
  • from \v8\include copy all v8*.h files to deps\include folder
  • within the PHP source code folder create a sub-directory named pecl
  • download V8Js and unpack it into a seperate directory below the pecl folder

(still in "VS2013 x86 Native Tools Command Prompt")

cd \php-sdk\phpdev\vc12\x86\php-5.5.18\

buildconf
configure --disable-all --enable-cli --with-v8js
nmake

After nmake completes the php.exe is in Release_TS\ directory.

In order to try things out in place, copy over icui18n.dll, icuuc.dll and v8.dll file from \v8\build\Release folder to \php-sdk\phpdev\vc12\x86\php-5.5.18\Release_TS\ first.

Then run

php.exe -d extension=php_v8js.dll -d extension_dir=\php-sdk\phpdev\vc12\x86\php-5.5.18\Release_TS\

Alternatively copy all stuff to c:\php\ (including the three DLL files from v8 build).