Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: fb74513525
Fetching contributors…

Cannot retrieve contributors at this time

file 70 lines (43 sloc) 1.623 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
php extension for Google's v8 javascript engine

Requires php 5.3+ and libv8 <http://code.google.com/p/v8/>

-Highly experimental-


NOTES
-----

The v8 javascript engine is not natively thread safe.
This extension does not work around it (at least for now).
Please use a single threaded sapi (CLI, fastcgi, fpm..)


INTERFACE
---------

The extension interface has been refactored to make it more similar
to the spidermonkey PECL extension <http://pecl.php.net/package/spidermonkey>

class V8Context {

  // php types for V8Context::set()
  const PHP_VALUE = 0;
  const PHP_FUNCTION= 1;
  const PHP_CLASS = 2;

  bool function set($var_name, $value [, $type = V8Context::PHP_VALUE]);

  mixed function get($var_name);

  bool function exists($var_name);

  bool function unset($var_name);

  // evals the js code and returns the result
  mixed function run($js_code);

  // same as set($js_name, $callable, V8Context::PHP_FUNCTION)
  bool registerFunction($callable [, $js_name]);

  // same as set($js_name, $class_name, V8Context::PHP_CLASS)
  bool registerClass($class_name [, $js_name]);
}


INSTALLATION
------------

phpize and php-config must be in your PATH.
If not, please specify their full path in the following commands.

$ cd /path/to/this/extension/v8

$ phpize
(or /path/to/phpize if phpize is not in your path)

$ ./configure --with-v8=/path/to/google/v8
(or ./configure --with-php-config=/path/to/php-config
if php-config is not in your path)

$ make

$ cp modules/v8.so /to/wherever/you/want/it

Add the following line to php.ini:
extension="/wherever/you/put/it/v8.so"

Restart your webserver
Something went wrong with that request. Please try again.