@@ -9,6 +9,56 @@ This extension is for PHP 7 only.
9
9
** This extension is still under heavy development and it public API may change without any warning. Use at your own risk.**
10
10
11
11
12
+ ## About
13
+ [ php-v8] ( https://github.com/pinepain/php-v8 ) is a PHP 7.x extension
14
+ that brings [ V8] ( https://developers.google.com/v8/intro ) JavaScript engine API to PHP with some abstraction in mind and
15
+ provides an accurate native V8 C++ API implementation available from PHP.
16
+
17
+ ** Key features:**
18
+ - provides up-to-date JavaScript engine with recent [ ECMA] ( http://kangax.github.io/compat-table ) features supported;
19
+ - accurate native V8 C++ API implementation available from PHP;
20
+ - solid experience between native V8 C++ API and V8 API in PHP;
21
+ - no magic; no assumption;
22
+ - does what it asked to do;
23
+ - hides complexity with isolates and contexts scope management under the hood;
24
+ - provides a both-way interaction with PHP and V8 objects, arrays and functions;
25
+ - execution time and memory limits;
26
+ - multiple isolates and contexts at the same time;
27
+ - it works;
28
+
29
+ With this extension almost all what native V8 C++ API provides can be used. It provides a way to pass php scalars,
30
+ objects and function to V8 runtime and specify interaction with passed values (objects and functions only, as scalars
31
+ become js scalars too). While specific functionality will be done in PHP userland rather then in C/C++ this extension,
32
+ it let get into V8 hacking faster, reduces time costs and let have more maintainable solution. And it doesn't make any
33
+ assumptions for you so you are the boss, it does exactly what you ask for.
34
+
35
+ With php-v8 you can even implement nodejs in PHP. Not sure whether anyone should/will do this anyway, but it's doable.
36
+
37
+ * NOTE: Most, if not all, methods are named like in V8 API - starting from capital letter. This PSR violation done
38
+ intentionally with the purpose to provide more solid experience between native V8 C++ API and V8 PHP API.*
39
+
40
+
41
+ ## Demo
42
+
43
+ Here is a [ Hello World] ( https://developers.google.com/v8/get_started#hello-world )
44
+ from V8 [ Getting Started] ( https://developers.google.com/v8/intro ) developers guide page implemented in PHP with php-v8:
45
+
46
+ ``` php
47
+ <?php
48
+ $isolate = new \V8\Isolate();
49
+ $context = new \V8\Context($isolate);
50
+ $source = new \V8\StringValue($isolate, "'Hello' + ', World!'");
51
+
52
+ $script = new \V8\Script($context, $source);
53
+ $result = $script->Run($context);
54
+
55
+ echo $result->ToString($context)->Value(), PHP_EOL;
56
+ ```
57
+
58
+ which will output ` Hello, World! ` . See how it shorter and readable from that C++ version? And it also doesn't limit you
59
+ from V8 API utilizing to implement more amazing stuff.
60
+
61
+
12
62
## Installation
13
63
14
64
### Requirements
0 commit comments